Class: NetConfGen::Block

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Block

Returns a new instance of Block.



16
17
18
# File 'lib/netconfgen/netconfgen.rb', line 16

def initialize(name)
  @name = name
end

Instance Attribute Details

#blockengineObject

Returns the value of attribute blockengine.



14
15
16
# File 'lib/netconfgen/netconfgen.rb', line 14

def blockengine
  @blockengine
end

#codeObject

Returns the value of attribute code.



14
15
16
# File 'lib/netconfgen/netconfgen.rb', line 14

def code
  @code
end

Instance Method Details

#renderObject



20
21
22
23
24
# File 'lib/netconfgen/netconfgen.rb', line 20

def render
  t = ERB.new(@code)
  str = t.result(@blockengine.context.instance_eval { binding })
  return str
end

#to_sObject



26
27
28
# File 'lib/netconfgen/netconfgen.rb', line 26

def to_s
  self.render
end