Class: MotionGiphy::Response
- Inherits:
-
Object
- Object
- MotionGiphy::Response
- Defined in:
- lib/motion-giphy/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#error ⇒ Object
Returns the value of attribute error.
-
#json ⇒ Object
Returns the value of attribute json.
-
#success ⇒ Object
Returns the value of attribute success.
Class Method Summary collapse
Instance Method Summary collapse
- #meta ⇒ Object
- #pagination ⇒ Object
- #process_data_as_batch ⇒ Object
- #process_data_as_singular ⇒ Object
- #success? ⇒ Boolean
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
17 18 19 |
# File 'lib/motion-giphy/response.rb', line 17 def data @data end |
#error ⇒ Object
Returns the value of attribute error.
17 18 19 |
# File 'lib/motion-giphy/response.rb', line 17 def error @error end |
#json ⇒ Object
Returns the value of attribute json.
17 18 19 |
# File 'lib/motion-giphy/response.rb', line 17 def json @json end |
#success ⇒ Object
Returns the value of attribute success.
17 18 19 |
# File 'lib/motion-giphy/response.rb', line 17 def success @success end |
Class Method Details
.build_with_result(result) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/motion-giphy/response.rb', line 3 def self.build_with_result(result) response = self.new if result.success? response.success = true response.json = result.object else response.success = false response.error = MotionGiphy::Error.new(result.error) end response end |
Instance Method Details
#meta ⇒ Object
31 32 33 |
# File 'lib/motion-giphy/response.rb', line 31 def @meta ||= MoptionGiphy::Meta.new(json["meta"]) end |
#pagination ⇒ Object
27 28 29 |
# File 'lib/motion-giphy/response.rb', line 27 def pagination @pages ||= MotionGiphy::Pagination.new(json["pagination"]) end |
#process_data_as_batch ⇒ Object
23 24 25 |
# File 'lib/motion-giphy/response.rb', line 23 def process_data_as_batch self.data = gif.process_batch(self.json["data"]) end |
#process_data_as_singular ⇒ Object
19 20 21 |
# File 'lib/motion-giphy/response.rb', line 19 def process_data_as_singular self.data = gif.new(self.json["data"]) end |
#success? ⇒ Boolean
35 36 37 |
# File 'lib/motion-giphy/response.rb', line 35 def success? @success end |