Class: Titi::Matcher::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/titi/ignore/matcher.rb

Overview

An abstract class from which to subclass specific HTML matchers.

A subclass is initialized with a selector and an optional matcher. The selector is an HTML path specification used to collect elements from the document. If initialized with a matcher, the matcher is used to return match information from the elements; else the inner HTML is returned. Subclasses decide how the selector will collect elements.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selector, matcher = nil, options = {}) ⇒ Base

Returns a new instance of Base.



17
18
19
20
21
# File 'lib/titi/ignore/matcher.rb', line 17

def initialize selector, matcher=nil, options={}
  self.selector = selector
  self.matcher  = matcher
  self.options  = options
end

Instance Attribute Details

#matcherObject

Returns the value of attribute matcher.



14
15
16
# File 'lib/titi/ignore/matcher.rb', line 14

def matcher
  @matcher
end

#optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/titi/ignore/matcher.rb', line 15

def options
  @options
end

#selectorObject

Returns the value of attribute selector.



13
14
15
# File 'lib/titi/ignore/matcher.rb', line 13

def selector
  @selector
end

Instance Method Details

#match(doc) ⇒ Object



23
24
25
# File 'lib/titi/ignore/matcher.rb', line 23

def match doc
  raise "Abstract class #{self.class}"
end