Class: PgMigrate::Properties
- Inherits:
-
Hash
- Object
- Hash
- PgMigrate::Properties
- Defined in:
- lib/pg_migrate/props.rb
Instance Method Summary collapse
-
#initialize(filename = nil) ⇒ Properties
constructor
A new instance of Properties.
- #to_s ⇒ Object
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_s ⇒ Object
15 16 17 |
# File 'lib/pg_migrate/props.rb', line 15 def to_s self.map { |k, v| " #{k}=#{v}" }.join("\n") end |