Class: Titi::Matcher::MatchProc

Inherits:
MatchFirstElement show all
Defined in:
lib/titi/ignore/matcher.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 Base

#matcher, #selector

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of MatchProc.



57
58
59
60
61
# File 'lib/titi/ignore/matcher.rb', line 57

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.



56
57
58
# File 'lib/titi/ignore/matcher.rb', line 56

def options
  @options
end

#procObject

Returns the value of attribute proc.



55
56
57
# File 'lib/titi/ignore/matcher.rb', line 55

def proc
  @proc
end

Instance Method Details

#match(doc) ⇒ Object



62
63
64
65
# File 'lib/titi/ignore/matcher.rb', line 62

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