Class: Properties

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

Instance Method Summary collapse

Constructor Details

#initializeProperties

Returns a new instance of Properties.



24
25
26
# File 'lib/common/properties.rb', line 24

def initialize
  @props = Hash.new
end

Instance Method Details

#get(key) ⇒ Object



29
30
31
# File 'lib/common/properties.rb', line 29

def get( key )
  return @props[key]
end

#load(inputStream) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/common/properties.rb', line 39

def load( inputStream )
  inputStream.each_line do |line|
      if ( /^[ \t]*#/.match( line ) != nil or /^[ \t]*$/.match( line ) != nil )
        # it is a comment line or empty line => skip it
      else
      match = /([^=]+)=(.*)/.match( line )
          key = match[1].strip
          value = match[2].strip
         @props[key] = value
    end
  end
end

#put(key, value) ⇒ Object



34
35
36
# File 'lib/common/properties.rb', line 34

def put( key, value )
  @props[key] = value
end