Class: BaconIpsum::Parser
- Inherits:
-
Object
- Object
- BaconIpsum::Parser
- Defined in:
- lib/bacon_ipsum/parser.rb
Overview
parser of results received from HTTP client
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, format) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(response, format) ⇒ Parser
Returns a new instance of Parser.
10 11 12 13 |
# File 'lib/bacon_ipsum/parser.rb', line 10 def initialize(response, format) @response = response @format = format end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
8 9 10 |
# File 'lib/bacon_ipsum/parser.rb', line 8 def format @format end |
#response ⇒ Object
Returns the value of attribute response.
8 9 10 |
# File 'lib/bacon_ipsum/parser.rb', line 8 def response @response end |
Instance Method Details
#parse ⇒ Object
15 16 17 18 19 20 |
# File 'lib/bacon_ipsum/parser.rb', line 15 def parse return unless response return response if format != 'json' JSON.parse(response) end |