Class: HeroixApi::Data
- Inherits:
-
Object
- Object
- HeroixApi::Data
- Defined in:
- lib/heroix_api/data.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Contains the data as an OpenStruct.
-
#meta_data ⇒ Object
Contains the response meta data as an OpenStruct.
Class Method Summary collapse
-
.from_response(response) ⇒ Object
Creates an HeroixApi::Data object from an Http::Response.
Instance Method Summary collapse
-
#initialize(data, meta_data) ⇒ Data
constructor
Constructor for HeroixApi::Data.
-
#page_numbers ⇒ Object
Gives the page numbers for a paginated resource This is an OpenStruct with the following members: [page_numbers.next] Number of the next page [page_numbers.prev] Number of the previous page [page_numbers.current] Number of the current page [page_numbers.first] Number of the first page of data [page_numbers.last] Number of the last page.
Constructor Details
#initialize(data, meta_data) ⇒ Data
Constructor for HeroixApi::Data
23 24 25 26 |
# File 'lib/heroix_api/data.rb', line 23 def initialize(data,) @data = data @meta_data = end |
Instance Attribute Details
#data ⇒ Object
Contains the data as an OpenStruct
15 16 17 |
# File 'lib/heroix_api/data.rb', line 15 def data @data end |
#meta_data ⇒ Object
Contains the response meta data as an OpenStruct
19 20 21 |
# File 'lib/heroix_api/data.rb', line 19 def @meta_data end |
Class Method Details
.from_response(response) ⇒ Object
Creates an HeroixApi::Data object from an Http::Response
30 31 32 33 34 |
# File 'lib/heroix_api/data.rb', line 30 def self.from_response(response) data = self.parse_data(response) = {:page_numbers => self.parse_link_headers(response)} self.new(data, ) end |
Instance Method Details
#page_numbers ⇒ Object
Gives the page numbers for a paginated resource This is an OpenStruct with the following members:
- page_numbers.next
-
Number of the next page
- page_numbers.prev
-
Number of the previous page
- page_numbers.current
-
Number of the current page
- page_numbers.first
-
Number of the first page of data
- page_numbers.last
-
Number of the last page
45 46 47 |
# File 'lib/heroix_api/data.rb', line 45 def page_numbers [:page_numbers] end |