lib/cfa/matcher.rb
# The constructor arguments are constraints to match on an element.
# All constraints are optional.
# All supplied constraints must match, so it is a conjunction.
# @param key           [Object,nil] if non-nil,
#   constrain to elements with the name "*key*"
# @param collection    [Object,nil] if non-nil,
#   constrain to elements with the name "*collection*[]"
# @param value_matcher [Object,Regexp,nil] if non-nil,
#   constrain to elements whose value is Object or matches Regexp
# @yieldparam blk_key   [Object]
# @yieldparam blk_value [Object]
# @yieldreturn      [Boolean] if the block is present,
#   constrain to elements for which the block(*blk_key*, *blk_value*)
#   returns true
The constructor arguments are constraints to match on an element.
All constraints are optional.
All supplied constraints must match, so it is a conjunction.
The constructor arguments are constraints to match on an element . All constraints are optional . All supplied constraints must match so it is a conjunction .
def value_match?(element, matcher)
      case matcher
      when nil then true
      when Regexp
        return false unless element[:value].is_a?(String)
        matcher =~ element[:value]
      else
        matcher == element[:value]
      end
    end
def value_match? ( element , matcher ) case matcher when nil then true when Regexp return false unless element [ :value ] . is_a? ( String ) matcher =~ element [ :value ] else matcher == element [ :value ] end end
The constructor arguments are constraints to match on an element.
The constructor arguments are constraints to match on an element .
if the block is present, constrain to elements for which the block(*blk_key*, *blk_value*) returns true
if the block is present constrain to elements for which the block ( * blk_key * * blk_value * ) returns true
Boolean
element
<not_specific>
matcher
<not_specific>
key
<not_specific>
if non-nil, constrain to elements with the name "*key*"
if non - nil constrain to elements with the name " * key * "
collection
<not_specific>
if non-nil, constrain to elements with the name "*collection*[]"
if non - nil constrain to elements with the name " * collection * [] "
value_matcher
<not_specific>
if non-nil, constrain to elements whose value is Object or matches Regexp
if non - nil constrain to elements whose value is Object or matches Regexp
<not_specific>
None