Class: Howl::Converter

Inherits:
Plugin
  • Object
show all
Defined in:
lib/howl/converter.rb

Direct Known Subclasses

MarkdownConverter, SassConverter

Constant Summary

Constants inherited from Plugin

Plugin::PRIORITIES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#extensionObject

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

Returns:

  • (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