Sha256: f0d6ca06142f6e0615f96a4f86c2778eeae05696d93e5cb2567df5509ee9c616
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
class Trocla::Formats class Base attr_reader :trocla def initialize(trocla) @trocla = trocla end def render(output,render_options={}) output end def expensive? self.class.expensive? end class << self def expensive(is_expensive) @expensive = is_expensive end def expensive? @expensive == true end 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}") 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
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
trocla-0.4.0 | lib/trocla/formats.rb |
trocla-ruby2-0.4.0 | lib/trocla/formats.rb |
trocla-0.3.0 | lib/trocla/formats.rb |