Class: Jupiter::TextTemplate
- Inherits:
-
Object
- Object
- Jupiter::TextTemplate
- Defined in:
- lib/jupiter/nagios.rb
Instance Method Summary collapse
-
#initialize(template) ⇒ TextTemplate
constructor
A new instance of TextTemplate.
- #run ⇒ Object
- #set(name, value) ⇒ Object
- #to_s ⇒ Object
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
#run ⇒ Object
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_s ⇒ Object
20 21 22 |
# File 'lib/jupiter/nagios.rb', line 20 def to_s() run() end |