Class: Raas::PageModel
- Defined in:
- lib/raas/models/page_model.rb
Overview
Represents the pagination information returned in a paginated API call
Instance Attribute Summary collapse
-
#elements_per_block ⇒ Integer
The number of elements per page.
-
#number ⇒ Integer
The page number.
-
#result_count ⇒ Integer
The number of results returned.
-
#total_count ⇒ Integer
The total number of results.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(number = nil, elements_per_block = nil, result_count = nil, total_count = nil) ⇒ PageModel
constructor
A new instance of PageModel.
Methods inherited from BaseModel
Constructor Details
#initialize(number = nil, elements_per_block = nil, result_count = nil, total_count = nil) ⇒ PageModel
Returns a new instance of PageModel.
33 34 35 36 37 38 39 40 41 |
# File 'lib/raas/models/page_model.rb', line 33 def initialize(number = nil, elements_per_block = nil, result_count = nil, total_count = nil) @number = number @elements_per_block = elements_per_block @result_count = result_count @total_count = total_count end |
Instance Attribute Details
#elements_per_block ⇒ Integer
The number of elements per page
13 14 15 |
# File 'lib/raas/models/page_model.rb', line 13 def elements_per_block @elements_per_block end |
#number ⇒ Integer
The page number
9 10 11 |
# File 'lib/raas/models/page_model.rb', line 9 def number @number end |
#result_count ⇒ Integer
The number of results returned
17 18 19 |
# File 'lib/raas/models/page_model.rb', line 17 def result_count @result_count end |
#total_count ⇒ Integer
The total number of results
21 22 23 |
# File 'lib/raas/models/page_model.rb', line 21 def total_count @total_count end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/raas/models/page_model.rb', line 44 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. number = hash['number'] elements_per_block = hash['elementsPerBlock'] result_count = hash['resultCount'] total_count = hash['totalCount'] # Create object from extracted values. PageModel.new(number, elements_per_block, result_count, total_count) end |
.names ⇒ Object
A mapping from model property names to API property names.
24 25 26 27 28 29 30 31 |
# File 'lib/raas/models/page_model.rb', line 24 def self.names @_hash = {} if @_hash.nil? @_hash['number'] = 'number' @_hash['elements_per_block'] = 'elementsPerBlock' @_hash['result_count'] = 'resultCount' @_hash['total_count'] = 'totalCount' @_hash end |