Class: Vidsy::Data::API::Response
- Inherits:
-
Object
- Object
- Vidsy::Data::API::Response
- Defined in:
- lib/vidsy/data/api/response.rb
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
13 14 15 |
# File 'lib/vidsy/data/api/response.rb', line 13 def initialize(response) @response = response end |
Class Method Details
.build(response) ⇒ Object
9 10 11 |
# File 'lib/vidsy/data/api/response.rb', line 9 def self.build(response) new(response).data end |
Instance Method Details
#data ⇒ Object
17 18 19 20 21 |
# File 'lib/vidsy/data/api/response.rb', line 17 def data raise unexpected_error unless response.body data = response.body["data"] || raise(response_error) data.map { |e| OpenStruct.new e } end |