Class: Hypem::Track

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

included, #update_from_response

Constructor Details

#initialize(arg) ⇒ Track

Returns a new instance of Track.



24
25
26
27
28
29
30
31
32
# File 'lib/hypem/track.rb', line 24

def initialize(arg)
  if arg.is_a? Hash
    update_from_response arg
  elsif arg.is_a? String
    @media_id = arg
  else
    raise
  end
end

Instance Attribute Details

#media_idObject

Returns the value of attribute media_id.



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

def media_id
  @media_id
end

Instance Method Details

#favorites(page = nil) ⇒ Object



40
41
42
# File 'lib/hypem/track.rb', line 40

def favorites(page=nil)
  @track_favorites ||= TrackFavorites.new(@media_id)
end

#getObject



34
35
36
37
38
# File 'lib/hypem/track.rb', line 34

def get
  response = Request.get_data("/playlist/item/#{media_id}")
  update_from_response response
  self
end