Class: Markup::Runner

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

Defined Under Namespace

Classes: OutputExists

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
# File 'lib/markup.rb', line 8

def initialize(source, options = {})
  @source  = source
  @options = options
end

Instance Method Details

#generate_html!Object



13
14
15
16
17
18
19
# File 'lib/markup.rb', line 13

def generate_html!
  if output_file_exists? && should_not_overwrite_output_file?
    raise OutputExists, output_filename
  else
    File.open(output_filename, 'w') { |f| f.write(html_output) }
  end
end

#output_filenameObject



21
22
23
# File 'lib/markup.rb', line 21

def output_filename
  @options[:output] || File.basename(@source, '.*') + '.html'
end