Class: Hearken::Track

Inherits:
Object
  • Object
show all
Includes:
Colour, Tagged
Defined in:
lib/hearken/track.rb

Constant Summary

Constants included from Tagged

Hearken::Tagged::FIELDS, Hearken::Tagged::FILE_FIELDS, Hearken::Tagged::TAG_FIELDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Colour

#c

Methods included from Tagged

#no_tag_fields?, #to_a

Constructor Details

#initialize(id = nil) ⇒ Track

Returns a new instance of Track.



13
14
15
# File 'lib/hearken/track.rb', line 13

def initialize(id = nil)
  @id = id
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#startedObject

Returns the value of attribute started.



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

def started
  @started
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/hearken/track.rb', line 17

def [](key)
  send key
end

#my(field, colour) ⇒ Object



49
50
51
# File 'lib/hearken/track.rb', line 49

def my(field, colour)
  c send(field).to_s, colour
end

#search_idObject



25
26
27
# File 'lib/hearken/track.rb', line 25

def search_id
  id.to_s 36
end

#search_stringObject



29
30
31
# File 'lib/hearken/track.rb', line 29

def search_string
  "#{artist.to_s.downcase}#{album.to_s.downcase}#{title.to_s.downcase}#{date}"
end

#to_sObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/hearken/track.rb', line 33

def to_s
  [
    "[#{my(:search_id, :white)}]",
    my(:artist, :yellow),
    my(:album, :cyan),
    my(:track, :magenta),
    my(:title, :green),
    my(:date, :white),
    my(:time, :white)
  ].join(" ")
end

#to_short_sObject



45
46
47
# File 'lib/hearken/track.rb', line 45

def to_short_s
  "#{track} #{title}\n#{artist}\n#{album}"
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/hearken/track.rb', line 21

def valid?
  @track
end