Class: UltimateLyrics::ProviderSearch
- Inherits:
-
Object
- Object
- UltimateLyrics::ProviderSearch
- Defined in:
- lib/ultimate_lyrics/provider_search.rb
Instance Method Summary collapse
- #escaped_url ⇒ String
- #lyrics ⇒ UltimateLyrics::Lyrics
- #lyrics_original_text ⇒ UltimateLyrics::Parser
- #parser ⇒ UltimateLyrics::Parser
- #to_s ⇒ Object
- #url ⇒ String
-
#url_fields ⇒ Object
[].
Instance Method Details
#escaped_url ⇒ String
14 15 16 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 14 def escaped_url ::Addressable::URI.escape(url) end |
#lyrics ⇒ UltimateLyrics::Lyrics
29 30 31 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 29 def lyrics ::UltimateLyrics::Lyrics.new(, provider.name, parser.result) end |
#lyrics_original_text ⇒ UltimateLyrics::Parser
34 35 36 37 38 39 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 34 def lyrics_original_text ::Aranha::Parsers::SourceAddress.detect_sub(escaped_url).content .force_encoding(provider.encoding) rescue ::Aranha::Parsers::SourceAddress::FetchContentError nil end |
#parser ⇒ UltimateLyrics::Parser
42 43 44 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 42 def parser ::UltimateLyrics::Parser.new(provider, lyrics_original_text) end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 46 def to_s "ProviderSearch[#{provider} | #{}]" end |
#url ⇒ String
19 20 21 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 19 def url url_fields.inject(provider.url) { |a, e| e.apply(a) } end |
#url_fields ⇒ Object
Returns [].
24 25 26 |
# File 'lib/ultimate_lyrics/provider_search.rb', line 24 def url_fields provider.url_fields.map { |provider_url_field| .field(provider_url_field) } end |