Class: IMW::Parsers::HtmlMatchers::Matcher
- Inherits:
-
Object
- Object
- IMW::Parsers::HtmlMatchers::Matcher
- 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.
Direct Known Subclasses
MatchArray, MatchAttribute, MatchFirstElement, MatchRegexp, MatchRegexpRepeatedly
Instance Attribute Summary collapse
-
#matcher ⇒ Object
Returns the value of attribute matcher.
-
#options ⇒ Object
Returns the value of attribute options.
-
#selector ⇒ Object
Returns the value of attribute selector.
Instance Method Summary collapse
-
#initialize(selector, matcher = nil, options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #match(doc) ⇒ Object
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, ={} self.selector = selector self.matcher = matcher self. = end |
Instance Attribute Details
#matcher ⇒ Object
Returns the value of attribute matcher.
18 19 20 |
# File 'lib/imw/parsers/html_parser/matchers.rb', line 18 def matcher @matcher end |
#options ⇒ Object
Returns the value of attribute options.
19 20 21 |
# File 'lib/imw/parsers/html_parser/matchers.rb', line 19 def @options end |
#selector ⇒ Object
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 |