Class: Snipcheat::Output
- Inherits:
-
Object
- Object
- Snipcheat::Output
- Defined in:
- lib/snipcheat/output.rb
Instance Method Summary collapse
-
#initialize(snippets, out_file) ⇒ Output
constructor
A new instance of Output.
- #to_s ⇒ Object
- #write ⇒ Object
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_s ⇒ Object
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 |
#write ⇒ Object
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 |