Class: Riddle::Configuration::Parser::InnerParser

Inherits:
Object
  • Object
show all
Defined in:
lib/riddle/configuration/parser.rb

Constant Summary collapse

SETTING_PATTERN =
/^(\w+)\s*=\s*(.*)$/
EndOfFileError =
Class.new StandardError

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ InnerParser

Returns a new instance of InnerParser.



142
143
144
145
# File 'lib/riddle/configuration/parser.rb', line 142

def initialize(input)
  @stream   = StringIO.new(input.gsub("\\\n", ''))
  @sections = {}
end

Instance Method Details

#parse!Object



147
148
149
150
151
152
153
154
155
# File 'lib/riddle/configuration/parser.rb', line 147

def parse!
  while label = next_line do
    @sections[label] = next_settings
  end

  @sections
rescue EndOfFileError
  @sections
end