Class: Gmortar::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/gmortar/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Template

Returns a new instance of Template.



3
4
5
6
7
8
9
# File 'lib/gmortar/template.rb', line 3

def initialize(name)
  path = File.expand_path(
    File.join(__dir__, "..","..", "templates", name)
  )

  @__erb = ERB.new File.read(path)
end

Instance Method Details

#resultObject



15
16
17
# File 'lib/gmortar/template.rb', line 15

def result
  @__erb.result binding
end

#set(key, value) ⇒ Object



11
12
13
# File 'lib/gmortar/template.rb', line 11

def set(key, value)
  instance_variable_set "@#{key}", value
end