Class: Vagalume::Song

Inherits:
Object
  • Object
show all
Defined in:
lib/vagalume/song.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(song) ⇒ Song

Returns a new instance of Song.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/vagalume/song.rb', line 5

def initialize(song)
  @id = song["id"]
  @language = song["lang"]
  @url = song["url"]
  @lyric = song["text"]
  @name = song["name"]

  if translation?
    @name = get_name_from_lyric(@lyric)
    @lyric = remove_title(@lyric)
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/vagalume/song.rb', line 3

def id
  @id
end

#languageObject

Returns the value of attribute language.



3
4
5
# File 'lib/vagalume/song.rb', line 3

def language
  @language
end

#lyricObject

Returns the value of attribute lyric.



3
4
5
# File 'lib/vagalume/song.rb', line 3

def lyric
  @lyric
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/vagalume/song.rb', line 3

def name
  @name
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/vagalume/song.rb', line 3

def url
  @url
end

Instance Method Details

#translation?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/vagalume/song.rb', line 18

def translation?
  @name.nil?
end