Class: HeroixApi::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/heroix_api/data.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#dataObject

Contains the data as an OpenStruct



15
16
17
# File 'lib/heroix_api/data.rb', line 15

def data
  @data
end

#meta_dataObject

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_numbersObject

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