Class: SlackWebApi::PagingObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/slack_web_api/models/paging_object.rb

Overview

PagingObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(page:, total:, count: SKIP, pages: SKIP, per_page: SKIP, spill: SKIP, additional_properties: nil) ⇒ PagingObject

Returns a new instance of PagingObject.



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/slack_web_api/models/paging_object.rb', line 63

def initialize(page:, total:, count: SKIP, pages: SKIP, per_page: SKIP,
               spill: SKIP, additional_properties: nil)
  # Add additional model properties to the instance

  additional_properties = {} if additional_properties.nil?

  @count = count unless count == SKIP
  @page = page
  @pages = pages unless pages == SKIP
  @per_page = per_page unless per_page == SKIP
  @spill = spill unless spill == SKIP
  @total = total
  @additional_properties = additional_properties
end

Instance Attribute Details

#countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/slack_web_api/models/paging_object.rb', line 14

def count
  @count
end

#pageInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/slack_web_api/models/paging_object.rb', line 18

def page
  @page
end

#pagesInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/slack_web_api/models/paging_object.rb', line 22

def pages
  @pages
end

#per_pageInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/slack_web_api/models/paging_object.rb', line 26

def per_page
  @per_page
end

#spillInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/slack_web_api/models/paging_object.rb', line 30

def spill
  @spill
end

#totalInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/slack_web_api/models/paging_object.rb', line 34

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/slack_web_api/models/paging_object.rb', line 78

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  page = hash.key?('page') ? hash['page'] : nil
  total = hash.key?('total') ? hash['total'] : nil
  count = hash.key?('count') ? hash['count'] : SKIP
  pages = hash.key?('pages') ? hash['pages'] : SKIP
  per_page = hash.key?('per_page') ? hash['per_page'] : SKIP
  spill = hash.key?('spill') ? hash['spill'] : SKIP

  # Create a new hash for additional properties, removing known properties.

  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.

  PagingObject.new(page: page,
                   total: total,
                   count: count,
                   pages: pages,
                   per_page: per_page,
                   spill: spill,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/slack_web_api/models/paging_object.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['count'] = 'count'
  @_hash['page'] = 'page'
  @_hash['pages'] = 'pages'
  @_hash['per_page'] = 'per_page'
  @_hash['spill'] = 'spill'
  @_hash['total'] = 'total'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/slack_web_api/models/paging_object.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
# File 'lib/slack_web_api/models/paging_object.rb', line 49

def self.optionals
  %w[
    count
    pages
    per_page
    spill
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
# File 'lib/slack_web_api/models/paging_object.rb', line 114

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} count: #{@count.inspect}, page: #{@page.inspect}, pages: #{@pages.inspect},"\
  " per_page: #{@per_page.inspect}, spill: #{@spill.inspect}, total: #{@total.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



107
108
109
110
111
# File 'lib/slack_web_api/models/paging_object.rb', line 107

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} count: #{@count}, page: #{@page}, pages: #{@pages}, per_page: #{@per_page},"\
  " spill: #{@spill}, total: #{@total}, additional_properties: #{@additional_properties}>"
end