Class: IMW::Parsers::HtmlMatchers::MatchProc

Inherits:
MatchFirstElement show all
Defined in:
lib/imw/parsers/html_parser/matchers.rb

Overview

FIXME is there really a need for this separate class? why can’t MatchFirstElement.match accept a block?

Instance Attribute Summary collapse

Attributes inherited from Matcher

#matcher, #selector

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of MatchProc.



61
62
63
64
65
# File 'lib/imw/parsers/html_parser/matchers.rb', line 61

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

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



60
61
62
# File 'lib/imw/parsers/html_parser/matchers.rb', line 60

def options
  @options
end

#procObject

Returns the value of attribute proc.



59
60
61
# File 'lib/imw/parsers/html_parser/matchers.rb', line 59

def proc
  @proc
end

Instance Method Details

#match(doc) ⇒ Object



66
67
68
69
# File 'lib/imw/parsers/html_parser/matchers.rb', line 66

def match doc
  val = super doc
  val ? self.proc.call(val) : self.proc.call(doc)
end