Class: IMW::Parsers::HtmlMatchers::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/imw/parsers/html_parser/matchers.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 = {}) ⇒ Matcher

Returns a new instance of Matcher.



21
22
23
24
25
# File 'lib/imw/parsers/html_parser/matchers.rb', line 21

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.



18
19
20
# File 'lib/imw/parsers/html_parser/matchers.rb', line 18

def matcher
  @matcher
end

#optionsObject

Returns the value of attribute options.



19
20
21
# File 'lib/imw/parsers/html_parser/matchers.rb', line 19

def options
  @options
end

#selectorObject

Returns the value of attribute selector.



17
18
19
# File 'lib/imw/parsers/html_parser/matchers.rb', line 17

def selector
  @selector
end

Instance Method Details

#match(doc) ⇒ Object



27
28
29
# File 'lib/imw/parsers/html_parser/matchers.rb', line 27

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