Class: PgMigrate::Properties

Inherits:
Hash
  • Object
show all
Defined in:
lib/pg_migrate/props.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename = nil) ⇒ Properties

Returns a new instance of Properties.



5
6
7
8
9
10
11
12
13
# File 'lib/pg_migrate/props.rb', line 5

def initialize(filename = nil)
  if (filename) then
    File.open(filename).select { |line| not line=~/^[ \t]*(#.+)*$/ }.# ignore comments and blank lines
    each { |line|
      (k, v) = line.chomp.split('=', 2)
      self[k.strip] = v.strip
    }
  end
end

Instance Method Details

#to_sObject



15
16
17
# File 'lib/pg_migrate/props.rb', line 15

def to_s
  self.map { |k, v| " #{k}=#{v}" }.join("\n")
end