Class: UltimateLyrics::Provider::Rule
- Inherits:
-
Object
- Object
- UltimateLyrics::Provider::Rule
- Defined in:
- lib/ultimate_lyrics/provider/rule.rb
Instance Method Summary collapse
- #apply(string) ⇒ Object
- #item_class ⇒ Object
- #items ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #url? ⇒ Boolean
Instance Method Details
#apply(string) ⇒ Object
16 17 18 |
# File 'lib/ultimate_lyrics/provider/rule.rb', line 16 def apply(string) url? ? apply_with_url(string) : apply_without_url(string) end |
#item_class ⇒ Object
12 13 14 |
# File 'lib/ultimate_lyrics/provider/rule.rb', line 12 def item_class ::UltimateLyrics::Provider.const_get(type.camelize + 'Item') end |
#items ⇒ Object
8 9 10 |
# File 'lib/ultimate_lyrics/provider/rule.rb', line 8 def items node.xpath('./item').map { |v| item_class.new(self, v) } end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/ultimate_lyrics/provider/rule.rb', line 20 def to_s "Rule[#{type} | #{items.join(', ')}]" end |
#type ⇒ Object
24 25 26 |
# File 'lib/ultimate_lyrics/provider/rule.rb', line 24 def type node.name end |
#url? ⇒ Boolean
28 29 30 |
# File 'lib/ultimate_lyrics/provider/rule.rb', line 28 def url? items.any?(&:url?) end |