Class: UltimateLyrics::Parser
- Inherits:
-
Object
- Object
- UltimateLyrics::Parser
- Defined in:
- lib/ultimate_lyrics/parser.rb
Instance Method Summary collapse
Instance Method Details
#original_content_invalid? ⇒ Boolean
9 10 11 |
# File 'lib/ultimate_lyrics/parser.rb', line 9 def original_content_invalid? provider.invalid_indicators.any? { |v| original_content.include?(v) } end |
#result ⇒ Object
13 14 15 16 17 |
# File 'lib/ultimate_lyrics/parser.rb', line 13 def result return nil if original_content_invalid? sanitize_text(provider.rules.inject(original_content) { |a, e| e.apply(a) }) end |
#sanitize_text(text) ⇒ Object
19 20 21 22 |
# File 'lib/ultimate_lyrics/parser.rb', line 19 def sanitize_text(text) r = text.to_s.gsub("\t", ' ').gsub("\r", '').gsub(/ +/, ' ').gsub(/\n{2,}/m, "\n\n").strip r.present? ? "#{r}\n" : nil end |
#url? ⇒ Boolean
24 25 26 |
# File 'lib/ultimate_lyrics/parser.rb', line 24 def url? provider.extract_rules.any?(&:url?) end |