Class: Console::ConfigFile
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- Console::ConfigFile
- Defined in:
- lib/console/config_file.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
Constructor Details
#initialize(file) ⇒ ConfigFile
Returns a new instance of ConfigFile.
3 4 5 6 7 8 9 10 11 |
# File 'lib/console/config_file.rb', line 3 def initialize(file) IO.read(File.(file)).lines. map{ |s| s.gsub(/((^|[^\\])(\\\\)*)#.*/,'\1') }. # eliminate unescaped comments each do |s| if pair = /^\s*(.*?[^\\]+?(?:\\\\)*)=(.*)$/.match(s) self[pair[1].strip.gsub(/\\(.)/,'\1')] = pair[2].strip.gsub(/\\(.)/,'\1') end end end |