Method: Spotify::Models::Paging#initialize

Defined in:
lib/spotify/models/paging.rb

#initialize(args = {}, klass) ⇒ Paging

Sets the arguments to its variables.

Parameters:

  • args (Hash) (defaults to: {})

    the arguments that will be placed on each variable.

  • klass (Spotify::Model)

    the model’s class that is represented on items’s array.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/spotify/models/paging.rb', line 19

def initialize(args = {}, klass)
  args = Hash(args).with_indifferent_access

  # Arrays
  items = Array(args[:items]).map { |i| klass.new(i) }

  @href     = args[:href]
  @items    = items
  @limit    = args[:limit]
  @next     = args[:next]
  @offset   = args[:offset]
  @previous = args[:previous]
  @total    = args[:total]
end