Class: UltimateLyrics::Provider::Item
- Inherits:
-
Object
- Object
- UltimateLyrics::Provider::Item
- Defined in:
- lib/ultimate_lyrics/provider/item.rb
Direct Known Subclasses
Constant Summary collapse
- METHODS_ATTRIBUTES =
{ tag: :tag, begin_with: :begin, end_with: :end, url: :url }.freeze
- TAG_NAME_PARSER =
/<(\w+).*>/.to_parser { |m| m[1] }
Instance Method Summary collapse
Instance Method Details
#apply(source) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/ultimate_lyrics/provider/item.rb', line 25 def apply(source) %w[url tag delimiters].each do |m| next unless send("#{m}?") return send("apply_from_#{m}", source) end raise 'Invalid branch hit' end |
#delimiters? ⇒ Boolean
21 22 23 |
# File 'lib/ultimate_lyrics/provider/item.rb', line 21 def delimiters? begin_with? || end_with? end |
#tag_name ⇒ Object
35 36 37 |
# File 'lib/ultimate_lyrics/provider/item.rb', line 35 def tag_name TAG_NAME_PARSER.parse(tag) end |
#to_s ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ultimate_lyrics/provider/item.rb', line 39 def to_s self.class.name.demodulize + '[' + METHODS_ATTRIBUTES .select { |m, _a| send(m).present? } .map { |m, a| "#{a}: #{send(m)}" } .join(', ') + ']' end |