Class: Checkup::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object = nil) ⇒ Template

Returns a new instance of Template.



8
9
10
11
12
13
14
15
16
# File 'lib/checkup/template.rb', line 8

def initialize(object = nil)
  if object.is_a?(Binding)
    @binding = object
  elsif object.is_a?(Hash)
    @binding = Checkup::Binder.new(object).get_binding
  else
    @binding = nil
  end
end

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



6
7
8
# File 'lib/checkup/template.rb', line 6

def binding
  @binding
end

Instance Method Details

#render(file) ⇒ Object



18
19
20
# File 'lib/checkup/template.rb', line 18

def render(file)
  puts result(file)
end

#result(file) ⇒ Object



22
23
24
# File 'lib/checkup/template.rb', line 22

def result(file)
  ERB.new(file_contents(file), nil, '<>').result(binding)
end