Class: Mako::Writer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#destinationObject (readonly)

Returns the value of attribute destination.



5
6
7
# File 'lib/mako/writer.rb', line 5

def destination
  @destination
end

#rendererObject (readonly)

Returns the value of attribute renderer.



5
6
7
# File 'lib/mako/writer.rb', line 5

def renderer
  @renderer
end

Instance Method Details

#writeObject



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