Class: Mitake::Parser Private
- Inherits:
-
Object
- Object
- Mitake::Parser
- Defined in:
- lib/mitake/parser.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Parse API response
Constant Summary collapse
- ID_MATCHER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\[(\d+)\]/.freeze
Instance Attribute Summary collapse
- #items ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(response) ⇒ Parser
constructor
private
A new instance of Parser.
-
#parse ⇒ Object
private
TODO: Improve response parser.
Constructor Details
#initialize(response) ⇒ Parser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Parser.
17 18 19 20 21 |
# File 'lib/mitake/parser.rb', line 17 def initialize(response) @response = response @body = response.body @items = [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/mitake/parser.rb', line 13 def items @items end |
Instance Method Details
#parse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: Improve response parser
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mitake/parser.rb', line 27 def parse @body.each_line do |line| next new_item(Regexp.last_match(1)) if line =~ ID_MATCHER key, value = line.strip.split('=') next if key.nil? current[key] = value end @items << current end |