Class: Songbirdsh::Track
- Inherits:
-
Object
- Object
- Songbirdsh::Track
- Defined in:
- lib/songbirdsh/track.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(id) ⇒ Track
constructor
A new instance of Track.
- #my(field, colour) ⇒ Object
- #search_id ⇒ Object
- #search_string ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(id) ⇒ Track
Returns a new instance of Track.
7 8 9 |
# File 'lib/songbirdsh/track.rb', line 7 def initialize id @id = id end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 |
# File 'lib/songbirdsh/track.rb', line 11 def [] key self.send key end |
#my(field, colour) ⇒ Object
31 32 33 |
# File 'lib/songbirdsh/track.rb', line 31 def my field, colour self.send(field).to_s.foreground(colour) end |
#search_id ⇒ Object
19 20 21 |
# File 'lib/songbirdsh/track.rb', line 19 def search_id id.to_s 36 end |
#search_string ⇒ Object
23 24 25 |
# File 'lib/songbirdsh/track.rb', line 23 def search_string "#{self.artist}#{self.album}#{self.track}" end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/songbirdsh/track.rb', line 27 def to_s "#{my(:search_id,:white)}: #{my(:artist, :yellow)} - #{my(:album,:cyan)} - #{my(:number,:magenta)} #{my(:track,:green)} (#{my(:duration,:white)})" end |
#valid? ⇒ Boolean
15 16 17 |
# File 'lib/songbirdsh/track.rb', line 15 def valid? @track end |