Class: Vagalume::Song

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

Class Method Details

.fetch(song_json) ⇒ Object



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

def self.fetch(song_json)
  song = Vagalume::Song.new
  song.id = song_json["id"]
  song.language = song_json["lang"]
  song.url = song_json["url"]
  song.lyric = song_json["text"]
  song.name = song_json["name"]
  if song.translation?
    song.name = get_name_from_lyric(song.lyric)
    song.lyric = remove_title(song.lyric)
  end
  song
end

Instance Method Details

#translation?Boolean

Returns:

  • (Boolean)


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

def translation?
  @name.nil?
end