class SlimLint::Matcher::Capture
Wraps a matcher, taking on the behavior of the wrapped matcher but storing the value that matched so it can be referred to later.
Attributes
matcher[RW]
@return [SlimLint::Matcher::Base] matcher that this capture wraps
value[RW]
@return [Object] value that was captured
Public Class Methods
from_matcher(matcher)
click to toggle source
Creates a capture that wraps that given matcher.
@param matcher [SlimLint::Matcher::Base] @return [SlimLint::Matcher::Capture]
# File lib/slim_lint/matcher/capture.rb, line 17 def self.from_matcher(matcher) new.tap do |cap_matcher| cap_matcher.matcher = matcher end end
Public Instance Methods
match?(object)
click to toggle source
@see {SlimLint::Matcher::Base#match?}
# File lib/slim_lint/matcher/capture.rb, line 24 def match?(object) if result = @matcher.match?(object) @value = object end result end