Class: Markout::Output

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Output

Returns a new instance of Output.



7
8
9
10
11
12
13
14
# File 'lib/markout/output.rb', line 7

def initialize(path, options = {})
  @path      = path
  @options   = options
  @document  = Document.new(@path, :history => @options[:history])
  @format    = @options[:format]   || 'html'
  @formatter = pick_formatter.new( @document, :template => @options[:template] || 'default' )
  @output    = ''
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



5
6
7
# File 'lib/markout/output.rb', line 5

def document
  @document
end

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/markout/output.rb', line 5

def format
  @format
end

#formatterObject (readonly)

Returns the value of attribute formatter.



5
6
7
# File 'lib/markout/output.rb', line 5

def formatter
  @formatter
end

Instance Method Details

#export(to_file = false) ⇒ Object



16
17
18
19
20
# File 'lib/markout/output.rb', line 16

def export(to_file=false)
  @output = @formatter.export
  write_file if to_file
  return @output
end

#output_pathObject



22
23
24
25
26
27
28
# File 'lib/markout/output.rb', line 22

def output_path
  if @options[:output]
    File.join( File.expand_path( @options[:output] ), @formatter.filename )
  else
    @document.base_path.join(@formatter.filename)
  end
end