Class: Ibanity::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/ibanity/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass:, items:, paging:, links:, synchronized_at:, latest_synchronization:) ⇒ Collection

Returns a new instance of Collection.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ibanity/collection.rb', line 19

def initialize(
  klass:,
  items:,
  paging:,
  links:,
  synchronized_at:,
  latest_synchronization:
)
  paging                ||= {}
  links                 ||= {}
  @klass                  = klass
  @page_limit             = paging["limit"]
  @page_number            = paging["pageNumber"]
  @page_size              = paging["pageSize"]
  @total_entries          = paging["totalEntries"]
  @total_pages            = paging["totalPages"]
  @before_cursor          = paging["before"]
  @after_cursor           = paging["after"]
  @offset                 = paging["offset"]
  @total                  = paging["total"]
  @first_link             = links["first"]
  @next_link              = links["next"]
  @previous_link          = links["prev"]
  @last_link              = links["last"]
  @synchronized_at        = synchronized_at
  @latest_synchronization = latest_synchronization
  super(items)
end

Instance Attribute Details

#after_cursorObject

Returns the value of attribute after_cursor.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def after_cursor
  @after_cursor
end

#before_cursorObject

Returns the value of attribute before_cursor.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def before_cursor
  @before_cursor
end

Returns the value of attribute first_link.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def first_link
  @first_link
end

Returns the value of attribute last_link.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def last_link
  @last_link
end

#latest_synchronizationObject

Returns the value of attribute latest_synchronization.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def latest_synchronization
  @latest_synchronization
end

Returns the value of attribute next_link.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def next_link
  @next_link
end

#offsetObject

Returns the value of attribute offset.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def offset
  @offset
end

#page_limitObject

Returns the value of attribute page_limit.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def page_limit
  @page_limit
end

#page_numberObject

Returns the value of attribute page_number.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def page_number
  @page_number
end

#page_sizeObject

Returns the value of attribute page_size.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def page_size
  @page_size
end

Returns the value of attribute previous_link.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def previous_link
  @previous_link
end

#synchronized_atObject

Returns the value of attribute synchronized_at.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def synchronized_at
  @synchronized_at
end

#totalObject

Returns the value of attribute total.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def total
  @total
end

#total_entriesObject

Returns the value of attribute total_entries.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def total_entries
  @total_entries
end

#total_pagesObject

Returns the value of attribute total_pages.



3
4
5
# File 'lib/ibanity/collection.rb', line 3

def total_pages
  @total_pages
end

Instance Method Details

#inspectObject



48
49
50
51
52
53
54
55
# File 'lib/ibanity/collection.rb', line 48

def inspect
  result = "#<#{self.class.name}"
  instance_variables.each do |instance_variable|
    result +=" #{instance_variable}=#{instance_variable_get(instance_variable).inspect}"
  end
  result += ">"
  result
end