Class: Howl::Converter
Direct Known Subclasses
Constant Summary
Constants inherited from Plugin
Instance Attribute Summary collapse
-
#extension ⇒ Object
Returns the value of attribute extension.
Class Method Summary collapse
Instance Method Summary collapse
- #convert(text) ⇒ Object
-
#initialize(template) ⇒ Converter
constructor
A new instance of Converter.
Methods inherited from Plugin
<=>, inherited, priority, subclasses
Constructor Details
#initialize(template) ⇒ Converter
Returns a new instance of Converter.
20 21 22 23 24 |
# File 'lib/howl/converter.rb', line 20 def initialize(template) @template = template ext_regexp = self.class.converts.find { |conversion| conversion[0].match(@template.extension) } @extension = @template.extension.gsub(ext_regexp[0], ext_regexp[1]) end |
Instance Attribute Details
#extension ⇒ Object
Returns the value of attribute extension.
18 19 20 |
# File 'lib/howl/converter.rb', line 18 def extension @extension end |
Class Method Details
.converts(hash = nil) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/howl/converter.rb', line 3 def self.converts(hash = nil) @converts ||= {} if hash @converts.merge!(hash) else @converts end end |
.matches?(ext) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/howl/converter.rb', line 12 def self.matches?(ext) @converts.keys.any? do |matcher| matcher.match(ext) end end |
Instance Method Details
#convert(text) ⇒ Object
26 27 28 |
# File 'lib/howl/converter.rb', line 26 def convert(text) text end |