Class: Kagu::Track
- Inherits:
-
Object
- Object
- Kagu::Track
- Includes:
- Comparable, AttributesInitializer
- Defined in:
- lib/kagu/track.rb
Constant Summary collapse
- MANDATORY_ATTRIBUTES =
%w(added_at id length).freeze
Instance Attribute Summary collapse
-
#added_at ⇒ Object
readonly
Returns the value of attribute added_at.
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#bpm ⇒ Object
readonly
Returns the value of attribute bpm.
-
#genre ⇒ Object
readonly
Returns the value of attribute genre.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #exists_on_disk? ⇒ Boolean
- #hash ⇒ Object
- #to_s ⇒ Object
Methods included from AttributesInitializer
Instance Attribute Details
#added_at ⇒ Object
Returns the value of attribute added_at.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def added_at @added_at end |
#album ⇒ Object
Returns the value of attribute album.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def album @album end |
#artist ⇒ Object
Returns the value of attribute artist.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def artist @artist end |
#bpm ⇒ Object
Returns the value of attribute bpm.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def bpm @bpm end |
#genre ⇒ Object
Returns the value of attribute genre.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def genre @genre end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def id @id end |
#length ⇒ Object
Returns the value of attribute length.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def length @length end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def path @path end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def title @title end |
#year ⇒ Object
Returns the value of attribute year.
10 11 12 |
# File 'lib/kagu/track.rb', line 10 def year @year end |
Instance Method Details
#<=>(other) ⇒ Object
12 13 14 15 |
# File 'lib/kagu/track.rb', line 12 def <=>(other) return nil unless other.is_a?(self.class) length <=> other.length end |
#==(other) ⇒ Object
17 18 19 |
# File 'lib/kagu/track.rb', line 17 def ==(other) other.is_a?(self.class) && artist == other.artist && title == other.title end |
#eql?(other) ⇒ Boolean
21 22 23 |
# File 'lib/kagu/track.rb', line 21 def eql?(other) super || self == other end |
#exists_on_disk? ⇒ Boolean
25 26 27 |
# File 'lib/kagu/track.rb', line 25 def exists_on_disk? path.present? && path.file? end |
#hash ⇒ Object
29 30 31 |
# File 'lib/kagu/track.rb', line 29 def hash [artist, title].hash end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/kagu/track.rb', line 33 def to_s "#{artist} - #{title}" end |