module Card::Format::Registration
Public Instance Methods
class_from_name(formatname)
click to toggle source
# File lib/card/format/registration.rb, line 38 def class_from_name formatname if formatname == "Format" Card::Format else Card::Format.const_get formatname end end
format_ancestry()
click to toggle source
# File lib/card/format/registration.rb, line 46 def format_ancestry ancestry = [self] ancestry += superclass.format_ancestry unless self == Card::Format ancestry end
format_class(opts)
click to toggle source
# File lib/card/format/registration.rb, line 17 def format_class opts return opts[:format_class] if opts[:format_class] format = opts[:format] || :html class_from_name format_class_name(format) end
format_class_name(format)
click to toggle source
# File lib/card/format/registration.rb, line 24 def format_class_name format format = format.to_s format = "" if format == "base" format = aliases[format] if aliases[format] "#{format.camelize}Format" end
format_sym(format)
click to toggle source
# File lib/card/format/registration.rb, line 31 def format_sym format return format if format.is_a? Symbol match = format.to_s.match(/::(?<format>[^:]+)Format/) match ? match[:format].underscore.to_sym : :base end
new(card, opts={})
click to toggle source
Calls superclass method
# File lib/card/format/registration.rb, line 8 def new card, opts={} if self != Format super else klass = format_class opts self == klass ? super : klass.new(card, opts) end end
register(format)
click to toggle source
# File lib/card/format/registration.rb, line 4 def register format registered << format.to_s end