Class: Hypem::TrackFavorites

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/hypem/track_favorites.rb

Constant Summary collapse

LIMIT =
20

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

included, #update_from_response

Constructor Details

#initialize(media_id, page = nil) ⇒ TrackFavorites

Returns a new instance of TrackFavorites.



9
10
11
12
13
# File 'lib/hypem/track_favorites.rb', line 9

def initialize(media_id, page=nil)
  page = 1 if page.nil?
  @media_id = media_id
  @page = page
end

Instance Attribute Details

#media_idObject

Returns the value of attribute media_id.



5
6
7
# File 'lib/hypem/track_favorites.rb', line 5

def media_id
  @media_id
end

#usersObject

Returns the value of attribute users.



5
6
7
# File 'lib/hypem/track_favorites.rb', line 5

def users
  @users
end

Instance Method Details

#getObject



15
16
17
18
19
# File 'lib/hypem/track_favorites.rb', line 15

def get
  user_ids = TrackFavoritesRequest.get_data(path)
  @users = user_ids.map{|user_id| User.new(user_id)}
  self
end

#next_pageObject



21
22
23
# File 'lib/hypem/track_favorites.rb', line 21

def next_page
  TrackFavorites.new(@media_id,@page+1).get
end

#page(num) ⇒ Object



29
30
31
# File 'lib/hypem/track_favorites.rb', line 29

def page(num)
  TrackFavorites.new(@media_id,num).get
end

#prev_pageObject



25
26
27
# File 'lib/hypem/track_favorites.rb', line 25

def prev_page
  TrackFavorites.new(@media_id,@page+1).get
end