Class: Mdopen::ErbTemplate

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/mdopen/erb_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, template) ⇒ ErbTemplate

Returns a new instance of ErbTemplate.



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

def initialize(content, template)
  @content = content
  @template = template
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/mdopen/erb_template.rb', line 6

def content
  @content
end

#templateObject

Returns the value of attribute template.



6
7
8
# File 'lib/mdopen/erb_template.rb', line 6

def template
  @template
end

Instance Method Details

#renderObject



13
14
15
# File 'lib/mdopen/erb_template.rb', line 13

def render()
  ERB.new(@template).result(binding)
end

#save(file) ⇒ Object



17
18
19
# File 'lib/mdopen/erb_template.rb', line 17

def save(file)
  File.write(file, render)
end