Class: Sexp::All
Overview
Matches only when all sub-expressions match.
This is also available via Matcher#&.
examples:
s(:a) / s{ all(s(:a), s(:b)) } #=> []
s(:a, :b) / s{ t(:a) & include(:b)) } #=> [s(:a, :b)]
Constant Summary
Constants inherited from Sexp
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
The collection of sub-matchers to match against.
Attributes inherited from Sexp
#comments, #file, #line, #line_max
Instance Method Summary collapse
-
#==(o) ⇒ Object
:nodoc:.
-
#initialize(*options) ⇒ All
constructor
Create an All matcher which will match all of the
options
. -
#inspect ⇒ Object
:nodoc:.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#satisfy?(o) ⇒ Boolean
Satisfied when all sub expressions match
o
.
Methods inherited from Matcher
#&, #-@, #/, #=~, #>>, #greedy?, match_subs=, match_subs?, parse, #|
Methods inherited from Sexp
#/, #=~, _, ___, all, any, #array_type?, atom, child, #compact, #deep_each, #depth, #each_of_type, #each_sexp, #eql?, #find_and_replace_all, #find_node, #find_nodes, from_array, #gsub, #hash, include, k, m, #map, #mass, #method_missing, #new, not?, q, #replace_sexp, #respond_to?, s, #search_each, #sexp_body, #sexp_body=, #sexp_type, #sexp_type=, #shift, #structure, #sub, t, #to_a, #value
Constructor Details
#initialize(*options) ⇒ All
Create an All matcher which will match all of the options
.
656 657 658 |
# File 'lib/sexp_matcher.rb', line 656 def initialize * @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sexp
Instance Attribute Details
#options ⇒ Object (readonly)
The collection of sub-matchers to match against.
651 652 653 |
# File 'lib/sexp_matcher.rb', line 651 def @options end |
Instance Method Details
#==(o) ⇒ Object
:nodoc:
669 670 671 |
# File 'lib/sexp_matcher.rb', line 669 def == o # :nodoc: super && self. == o. end |
#inspect ⇒ Object
:nodoc:
673 674 675 |
# File 'lib/sexp_matcher.rb', line 673 def inspect # :nodoc: .map(&:inspect).join(" & ") end |
#pretty_print(q) ⇒ Object
:nodoc:
677 678 679 680 681 682 683 |
# File 'lib/sexp_matcher.rb', line 677 def pretty_print q # :nodoc: q.group 1, "all(", ")" do q.seplist do |v| q.pp v end end end |
#satisfy?(o) ⇒ Boolean
Satisfied when all sub expressions match o
663 664 665 666 667 |
# File 'lib/sexp_matcher.rb', line 663 def satisfy? o .all? { |exp| exp.kind_of?(Sexp) ? exp.satisfy?(o) : exp == o } end |