Class: Snipcheat::Output

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

Instance Method Summary collapse

Constructor Details

#initialize(snippets, out_file) ⇒ Output

Returns a new instance of Output.



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

def initialize(snippets, out_file)
  @snippets = snippets
  @out_file = out_file
end

Instance Method Details

#to_sObject



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

def to_s
  engine = Haml::Engine.new(template('simple.html.haml'), escape_html: true)
  engine.render(Object.new, snippets: @snippets, css: template('styles.css'))
end

#writeObject



10
11
12
13
14
# File 'lib/snipcheat/output.rb', line 10

def write
  File.open(@out_file, 'w') do |f|
    f.write(to_s)
  end
end