Class: Jupiter::TextTemplate

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

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ TextTemplate

Returns a new instance of TextTemplate.



4
5
6
7
# File 'lib/jupiter/nagios.rb', line 4

def initialize( template )
  @template = template.clone()
  @values = {}
end

Instance Method Details

#runObject



13
14
15
16
17
18
# File 'lib/jupiter/nagios.rb', line 13

def run()
  @template.gsub( /:::(.*?):::/ ) {
    raise "Key '#{$1}' found in template but the value has not been set" unless ( @values.has_key?( $1 ) )
    @values[ $1 ].to_s
  }
end

#set(name, value) ⇒ Object



9
10
11
# File 'lib/jupiter/nagios.rb', line 9

def set( name, value )
  @values[ name ] = value
end

#to_sObject



20
21
22
# File 'lib/jupiter/nagios.rb', line 20

def to_s()
  run()
end