Class: ImageCollage::ResponseParser
- Inherits:
-
Object
- Object
- ImageCollage::ResponseParser
- Defined in:
- lib/imagecollage/flickr_api.rb
Constant Summary collapse
- PHOTO_PATH =
['rsp', 'photos', 'photo'].freeze
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize(response) ⇒ ResponseParser
constructor
A new instance of ResponseParser.
- #photo_data ⇒ Object
Constructor Details
#initialize(response) ⇒ ResponseParser
Returns a new instance of ResponseParser.
42 43 44 |
# File 'lib/imagecollage/flickr_api.rb', line 42 def initialize(response) @response = response # TODO Wrap in a Hash if needed end |
Instance Method Details
#fetch(key) ⇒ Object
46 47 48 |
# File 'lib/imagecollage/flickr_api.rb', line 46 def fetch(key) photo_data[key] end |
#photo_data ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/imagecollage/flickr_api.rb', line 50 def photo_data @_photo_data ||= PHOTO_PATH.reduce(@response) do |subdata, el| break unless subdata subdata[el] end @_photo_data || {} end |