Class: Karaoke::Song::Lyricsmode

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from Karaoke::Song::Base

Class Method Details

.matches?(lyrics_url) ⇒ Boolean

Returns:

  • (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

#artistObject



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

#lyricsObject



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

#titleObject



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