Class: Mako::Writer
- Inherits:
-
Object
- Object
- Mako::Writer
- Defined in:
- lib/mako/writer.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#initialize(args) ⇒ Writer
constructor
A new instance of Writer.
- #write ⇒ Object
Constructor Details
#initialize(args) ⇒ Writer
Returns a new instance of Writer.
7 8 9 10 |
# File 'lib/mako/writer.rb', line 7 def initialize(args) @renderer = args.fetch(:renderer) @destination = args.fetch(:destination) end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
5 6 7 |
# File 'lib/mako/writer.rb', line 5 def destination @destination end |
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
5 6 7 |
# File 'lib/mako/writer.rb', line 5 def renderer @renderer end |
Instance Method Details
#write ⇒ Object
12 13 14 15 16 |
# File 'lib/mako/writer.rb', line 12 def write File.open(destination, 'w+', encoding: 'utf-8') do |f| f.write(renderer.render) end end |