Class: Soundcloud9000::Models::Track
- Inherits:
-
Object
- Object
- Soundcloud9000::Models::Track
- Defined in:
- lib/soundcloud9000/models/track.rb
Overview
stores information for each track that hits the player
Instance Method Summary collapse
- #comments ⇒ Object
- #duration ⇒ Object
- #id ⇒ Object
-
#initialize(hash) ⇒ Track
constructor
A new instance of Track.
- #length ⇒ Object
- #likes ⇒ Object
- #stream_url ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #user ⇒ Object
- #username ⇒ Object
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
#comments ⇒ Object
45 46 47 |
# File 'lib/soundcloud9000/models/track.rb', line 45 def comments @hash['comment_count'] end |
#duration ⇒ Object
33 34 35 |
# File 'lib/soundcloud9000/models/track.rb', line 33 def duration @hash['duration'] end |
#id ⇒ Object
13 14 15 |
# File 'lib/soundcloud9000/models/track.rb', line 13 def id @hash['id'] end |
#length ⇒ Object
37 38 39 |
# File 'lib/soundcloud9000/models/track.rb', line 37 def length TimeHelper.duration(duration) end |
#likes ⇒ Object
41 42 43 |
# File 'lib/soundcloud9000/models/track.rb', line 41 def likes @hash['favoritings_count'] end |
#stream_url ⇒ Object
49 50 51 |
# File 'lib/soundcloud9000/models/track.rb', line 49 def stream_url @hash['stream_url'] end |
#title ⇒ Object
17 18 19 |
# File 'lib/soundcloud9000/models/track.rb', line 17 def title @hash['title'] end |
#url ⇒ Object
21 22 23 |
# File 'lib/soundcloud9000/models/track.rb', line 21 def url @hash['permalink_url'] end |
#user ⇒ Object
25 26 27 |
# File 'lib/soundcloud9000/models/track.rb', line 25 def user @user ||= User.new(@hash['user']) end |
#username ⇒ Object
29 30 31 |
# File 'lib/soundcloud9000/models/track.rb', line 29 def username user.username end |