Class: Vimeo::Collection

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, total:, next_page_token:, prev_page_token:) ⇒ Collection

Returns a new instance of Collection.



17
18
19
20
21
22
# File 'lib/vimeo/collection.rb', line 17

def initialize(data:, total:, next_page_token:, prev_page_token:)
  @data = data
  @total = total
  @next_page_token = next_page_token
  @prev_page_token = prev_page_token
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#next_page_tokenObject (readonly)

Returns the value of attribute next_page_token.



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

def next_page_token
  @next_page_token
end

#prev_page_tokenObject (readonly)

Returns the value of attribute prev_page_token.



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

def prev_page_token
  @prev_page_token
end

#totalObject (readonly)

Returns the value of attribute total.



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

def total
  @total
end

Class Method Details

.from_response(response, type:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/vimeo/collection.rb', line 5

def self.from_response(response, type:)
  body = response.body

  new(
    data: body["items"].map { |attrs| type.new(attrs) },
    total: body["pageInfo"]["totalResults"],
    next_page_token: body["nextPageToken"],
    prev_page_token: body["prevPageToken"],
    # cursor: body.dig("pagination", "cursor")
  )
end