Class: Raas::PageModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/page_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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_blockInteger

Elements per page

Returns:

  • (Integer)


11
12
13
# File 'lib/raas/models/page_model.rb', line 11

def elements_per_block
  @elements_per_block
end

#numberInteger

Page Number

Returns:

  • (Integer)


7
8
9
# File 'lib/raas/models/page_model.rb', line 7

def number
  @number
end

#result_countInteger

Result Count

Returns:

  • (Integer)


15
16
17
# File 'lib/raas/models/page_model.rb', line 15

def result_count
  @result_count
end

#total_countInteger

Total Count

Returns:

  • (Integer)


19
20
21
# File 'lib/raas/models/page_model.rb', line 19

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

.namesObject

A mapping from model property names to API property names



22
23
24
25
26
27
28
29
30
31
# File 'lib/raas/models/page_model.rb', line 22

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["number"] = "number"
    @_hash["elements_per_block"] = "elementsPerBlock"
    @_hash["result_count"] = "resultCount"
    @_hash["total_count"] = "totalCount"
  end
  @_hash
end