Class: Soundcloud2000::Models::Track

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

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Track

Returns a new instance of Track.



7
8
9
# File 'lib/soundcloud2000/models/track.rb', line 7

def initialize(hash)
  @hash = hash
end

Instance Method Details

#commentsObject



47
48
49
# File 'lib/soundcloud2000/models/track.rb', line 47

def comments
  @hash['comments']
end

#durationObject



31
32
33
# File 'lib/soundcloud2000/models/track.rb', line 31

def duration
  @hash['duration']
end

#idObject



11
12
13
# File 'lib/soundcloud2000/models/track.rb', line 11

def id
  @hash['id']
end

#lengthObject



35
36
37
# File 'lib/soundcloud2000/models/track.rb', line 35

def length
  TimeHelper.duration(duration)
end

#likesObject



43
44
45
# File 'lib/soundcloud2000/models/track.rb', line 43

def likes
  @hash['favoritings_count']
end

#playsObject



39
40
41
# File 'lib/soundcloud2000/models/track.rb', line 39

def plays
  @hash['playback_count']
end

#stream_urlObject



51
52
53
# File 'lib/soundcloud2000/models/track.rb', line 51

def stream_url
  @hash['stream_url']
end

#titleObject



15
16
17
# File 'lib/soundcloud2000/models/track.rb', line 15

def title
  @hash['title']
end

#urlObject



19
20
21
# File 'lib/soundcloud2000/models/track.rb', line 19

def url
  @hash['permalink_url']
end

#userObject



23
24
25
# File 'lib/soundcloud2000/models/track.rb', line 23

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

#usernameObject



27
28
29
# File 'lib/soundcloud2000/models/track.rb', line 27

def username
  user.username
end