summaryrefslogtreecommitdiff
path: root/lib/trocla/formats.rb
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2014-06-27 19:23:20 +0200
committermh <mh@immerda.ch>2014-06-27 19:23:20 +0200
commitecb2a2c7c6ec3576bc49747a484fa0f8e93a50fa (patch)
tree05ccf120e136b3d6d77a8d91f9930f0139b8e54b /lib/trocla/formats.rb
parent20de208ee827cb451e60705180909ce81eae0127 (diff)
parent08ac533d2156b666ae6ca68e797992629051315f (diff)
Merge branch 'tilya-charset_option'
Diffstat (limited to 'lib/trocla/formats.rb')
-rw-r--r--lib/trocla/formats.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/trocla/formats.rb b/lib/trocla/formats.rb
index 3cf31bd..0103c4e 100644
--- a/lib/trocla/formats.rb
+++ b/lib/trocla/formats.rb
@@ -1,32 +1,40 @@
class Trocla::Formats
+
+ class Base
+ attr_reader :trocla
+ def initialize(trocla)
+ @trocla = trocla
+ end
+ end
+
class << self
def [](format)
formats[format.downcase]
end
-
+
def all
Dir[File.expand_path(File.join(File.dirname(__FILE__),'formats','*.rb'))].collect{|f| File.basename(f,'.rb').downcase }
end
-
+
def available?(format)
all.include?(format.downcase)
end
-
+
private
def formats
@@formats ||= Hash.new do |hash, format|
format = format.downcase
if File.exists?(path(format))
require "trocla/formats/#{format}"
- hash[format] = (eval "Trocla::Formats::#{format.capitalize}").new
+ hash[format] = (eval "Trocla::Formats::#{format.capitalize}")
else
raise "Format #{format} is not supported!"
end
end
end
-
+
def path(format)
File.expand_path(File.join(File.dirname(__FILE__),'formats',"#{format}.rb"))
end
end
-end \ No newline at end of file
+end