Class: MediaWikiLyrics::TrackData

Inherits:
Object
  • Object
show all
Defined in:
lib/wiki_lyrics/mediawikilyrics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(artist, title, length = nil, genre = nil) ⇒ TrackData



38
39
40
41
42
43
44
45
46
47
# File 'lib/wiki_lyrics/mediawikilyrics.rb', line 38

def initialize( artist, title, length=nil, genre=nil )
  @artist = artist.strip().freeze()
  @title = title.strip().freeze()
  @length = 0
  if length
    tokens = length.to_s().split( ":" ).reverse()
    tokens.size.times() { |idx| @length += (60**idx) * tokens[idx].strip().to_i() }
  end
  @genre = genre ? genre.strip().freeze() : nil
end

Instance Attribute Details

#artistObject (readonly)

Returns the value of attribute artist.



36
37
38
# File 'lib/wiki_lyrics/mediawikilyrics.rb', line 36

def artist
  @artist
end

#genreObject (readonly)

Returns the value of attribute genre.



36
37
38
# File 'lib/wiki_lyrics/mediawikilyrics.rb', line 36

def genre
  @genre
end

#lengthObject (readonly)

Returns the value of attribute length.



36
37
38
# File 'lib/wiki_lyrics/mediawikilyrics.rb', line 36

def length
  @length
end

#titleObject (readonly)

Returns the value of attribute title.



36
37
38
# File 'lib/wiki_lyrics/mediawikilyrics.rb', line 36

def title
  @title
end

#yearObject (readonly)

Returns the value of attribute year.



36
37
38
# File 'lib/wiki_lyrics/mediawikilyrics.rb', line 36

def year
  @year
end