class Trocla::Formats

Public Class Methods

[](format) click to toggle source
# File lib/trocla/formats.rb, line 25
def [](format)
  formats[format.downcase]
end
all() click to toggle source
# File lib/trocla/formats.rb, line 29
def all
  Dir[File.expand_path(File.join(File.dirname(__FILE__),'formats','*.rb'))].collect{|f| File.basename(f,'.rb').downcase }
end
available?(format) click to toggle source
# File lib/trocla/formats.rb, line 33
def available?(format)
  all.include?(format.downcase)
end

Private Class Methods

formats() click to toggle source
# File lib/trocla/formats.rb, line 38
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}")
    else
      raise "Format #{format} is not supported!"
    end
  end
end
path(format) click to toggle source
# File lib/trocla/formats.rb, line 50
def path(format)
  File.expand_path(File.join(File.dirname(__FILE__),'formats',"#{format}.rb"))
end