Class: Markout::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/markout/formatter.rb

Direct Known Subclasses

Html, Pdf

Instance Method Summary collapse

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, options={})
  @document = document
  @options  = options
  @format   = self.class.to_s.gsub(/^.*::/, '').downcase
end

Instance Method Details

#exportObject

Raises:

  • (NoMethodError)


13
14
15
# File 'lib/markout/formatter.rb', line 13

def export
  raise NoMethodError, "Return String in `export()` method of your formatter (#{@format})"
end

#filenameObject



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