Class: Notu::Track
Instance Attribute Summary collapse
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#plays_count ⇒ Object
readonly
Returns the value of attribute plays_count.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Track
constructor
A new instance of Track.
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Track
Returns a new instance of Track.
9 10 11 12 13 14 |
# File 'lib/notu/track.rb', line 9 def initialize(attributes = {}) attributes = attributes.stringify_keys self.artist = attributes['artist'] self.plays_count = attributes['plays_count'] self.title = attributes['title'] end |
Instance Attribute Details
#artist ⇒ Object
Returns the value of attribute artist.
7 8 9 |
# File 'lib/notu/track.rb', line 7 def artist @artist end |
#plays_count ⇒ Object
Returns the value of attribute plays_count.
7 8 9 |
# File 'lib/notu/track.rb', line 7 def plays_count @plays_count end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/notu/track.rb', line 7 def title @title end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 19 20 |
# File 'lib/notu/track.rb', line 16 def <=>(other) return nil unless other.is_a?(Track) result = (artist <=> other.artist) result.zero? ? (title <=> other.title) : result end |
#==(other) ⇒ Object
22 23 24 |
# File 'lib/notu/track.rb', line 22 def ==(other) other.is_a?(self.class) && artist == other.artist && title == other.title end |
#eql?(other) ⇒ Boolean
26 27 28 |
# File 'lib/notu/track.rb', line 26 def eql?(other) super || self == other end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/notu/track.rb', line 30 def to_s "#{artist} - #{title}" end |