Class: Songbirdsh::Track

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

Instance Method Summary collapse

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_idObject



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

def search_id
  id.to_s 36
end

#search_stringObject



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

def search_string
  "#{self.artist}#{self.album}#{self.track}"
end

#to_sObject



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

Returns:

  • (Boolean)


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

def valid?
  @track
end