Class: Markout::Formatter
- Inherits:
-
Object
- Object
- Markout::Formatter
- Defined in:
- lib/markout/formatter.rb
Instance Method Summary collapse
- #export ⇒ Object
- #filename ⇒ Object
-
#initialize(document, options = {}) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(document, options = {}) ⇒ Formatter
Returns a new instance of Formatter.
7 8 9 10 11 |
# File 'lib/markout/formatter.rb', line 7 def initialize(document, ={}) @document = document @options = @format = self.class.to_s.gsub(/^.*::/, '').downcase end |
Instance Method Details
#export ⇒ Object
13 14 15 |
# File 'lib/markout/formatter.rb', line 13 def export raise NoMethodError, "Return String in `export()` method of your formatter (#{@format})" end |
#filename ⇒ Object
17 18 19 20 21 |
# File 'lib/markout/formatter.rb', line 17 def filename basename = File.basename(@document.path).split('.') ext = basename.pop "#{basename.join('.')}.#{@format}" end |