Class: Sexp::Pattern
Overview
Direct Known Subclasses
Constant Summary
Constants inherited from Sexp
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
The regexp to match for the pattern.
Attributes inherited from Sexp
#comments, #file, #line, #line_max
Instance Method Summary collapse
-
#==(o) ⇒ Object
:nodoc:.
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(pattern) ⇒ Pattern
constructor
Create a Patten matcher which will match any atom that either matches the input
pattern
. -
#inspect ⇒ Object
:nodoc:.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#satisfy?(o) ⇒ Boolean
Satisfied if
o
is an atom, ando
matchespattern
.
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, #find_and_replace_all, #find_node, #find_nodes, from_array, #gsub, 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(pattern) ⇒ Pattern
Create a Patten matcher which will match any atom that either matches the input pattern
.
834 835 836 |
# File 'lib/sexp_matcher.rb', line 834 def initialize pattern @pattern = pattern end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sexp
Instance Attribute Details
#pattern ⇒ Object (readonly)
The regexp to match for the pattern.
824 825 826 |
# File 'lib/sexp_matcher.rb', line 824 def pattern @pattern end |
Instance Method Details
#==(o) ⇒ Object
:nodoc:
826 827 828 |
# File 'lib/sexp_matcher.rb', line 826 def == o # :nodoc: super && self.pattern == o.pattern end |
#eql?(o) ⇒ Boolean
855 856 857 |
# File 'lib/sexp_matcher.rb', line 855 def eql? o super and self.pattern.eql? o.pattern end |
#hash ⇒ Object
859 860 861 |
# File 'lib/sexp_matcher.rb', line 859 def hash [super, pattern].hash end |
#inspect ⇒ Object
:nodoc:
845 846 847 |
# File 'lib/sexp_matcher.rb', line 845 def inspect # :nodoc: "m(%p)" % pattern end |
#pretty_print(q) ⇒ Object
:nodoc:
849 850 851 852 853 |
# File 'lib/sexp_matcher.rb', line 849 def pretty_print q # :nodoc: q.group 1, "m(", ")" do q.pp pattern end end |
#satisfy?(o) ⇒ Boolean
Satisfied if o
is an atom, and o
matches pattern
841 842 843 |
# File 'lib/sexp_matcher.rb', line 841 def satisfy? o !o.kind_of?(Sexp) && o.to_s =~ pattern # TODO: question to_s end |