Class: Soundcloud9000::Models::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/soundcloud9000/models/track.rb

Overview

stores information for each track that hits the player

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Track

Returns a new instance of Track.



8
9
10
11
# File 'lib/soundcloud9000/models/track.rb', line 8

def initialize(hash)
  Application.logger.debug(hash)
  @hash = hash
end

Instance Method Details

#commentsObject



45
46
47
# File 'lib/soundcloud9000/models/track.rb', line 45

def comments
  @hash['comment_count']
end

#durationObject



33
34
35
# File 'lib/soundcloud9000/models/track.rb', line 33

def duration
  @hash['duration']
end

#idObject



13
14
15
# File 'lib/soundcloud9000/models/track.rb', line 13

def id
  @hash['id']
end

#lengthObject



37
38
39
# File 'lib/soundcloud9000/models/track.rb', line 37

def length
  TimeHelper.duration(duration)
end

#likesObject



41
42
43
# File 'lib/soundcloud9000/models/track.rb', line 41

def likes
  @hash['favoritings_count']
end

#stream_urlObject



49
50
51
# File 'lib/soundcloud9000/models/track.rb', line 49

def stream_url
  @hash['stream_url']
end

#titleObject



17
18
19
# File 'lib/soundcloud9000/models/track.rb', line 17

def title
  @hash['title']
end

#urlObject



21
22
23
# File 'lib/soundcloud9000/models/track.rb', line 21

def url
  @hash['permalink_url']
end

#userObject



25
26
27
# File 'lib/soundcloud9000/models/track.rb', line 25

def user
  @user ||= User.new(@hash['user'])
end

#usernameObject



29
30
31
# File 'lib/soundcloud9000/models/track.rb', line 29

def username
  user.username
end