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.



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

def initialize(name)
  @name = name
end

Instance Attribute Details

#blockengineObject

Returns the value of attribute blockengine.



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

def blockengine
  @blockengine
end

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

Instance Method Details

#renderObject



17
18
19
20
21
# File 'lib/netconfgen/netconfgen.rb', line 17

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

#to_sObject



23
24
25
# File 'lib/netconfgen/netconfgen.rb', line 23

def to_s
  self.render
end