Class: UltimateLyrics::Provider::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/ultimate_lyrics/provider/rule.rb

Instance Method Summary collapse

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_classObject



12
13
14
# File 'lib/ultimate_lyrics/provider/rule.rb', line 12

def item_class
  ::UltimateLyrics::Provider.const_get(type.camelize + 'Item')
end

#itemsObject



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_sObject



20
21
22
# File 'lib/ultimate_lyrics/provider/rule.rb', line 20

def to_s
  "Rule[#{type} | #{items.join(', ')}]"
end

#typeObject



24
25
26
# File 'lib/ultimate_lyrics/provider/rule.rb', line 24

def type
  node.name
end

#url?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ultimate_lyrics/provider/rule.rb', line 28

def url?
  items.any?(&:url?)
end