Class: Karaoke::Song::Lyricsmode
- Inherits:
-
Base
- Object
- Base
- Karaoke::Song::Lyricsmode
show all
- Defined in:
- lib/karaoke/song/lyricsmode.rb
Instance Attribute Summary
Attributes inherited from Base
#lyrics_url
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.matches?(lyrics_url) ⇒ Boolean
8
9
10
|
# File 'lib/karaoke/song/lyricsmode.rb', line 8
def self.matches?(lyrics_url)
URI.parse(lyrics_url).host.end_with?("lyricsmode.com")
end
|
Instance Method Details
#artist ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/karaoke/song/lyricsmode.rb', line 12
def artist
return @artist if defined?(@artist)
el = document.css(%Q{a[data-tracking='\["Meta","Lyrics","ArtistName"\]']}).first
return @artist = nil unless el
@artist = el.text
end
|
#lyrics ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/karaoke/song/lyricsmode.rb', line 30
def lyrics
return @lyrics if defined?(@lyrics)
el = document.css(".meaning_inside_frame").first
return @lyrics = nil unless el
@lyrics = clean_html(el.inner_html)
end
|
#title ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/karaoke/song/lyricsmode.rb', line 21
def title
return @title if defined?(@title)
el = document.css("h1.song_name").first
return @title = nil unless el
@title = el.text.trim.match("^(.+?) Lyrics$")[1]
end
|