Class: Sexp::Pattern
Overview
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
The regexp to match for the pattern.
Attributes inherited from Sexp
Instance Method Summary collapse
-
#==(o) ⇒ Object
:nodoc:.
-
#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, #line_max, m, #map, #mass, #method_missing, #new, not?, #replace_sexp, #respond_to?, s, #search_each, #sexp_body, #sexp_body=, #sexp_type, #sexp_type=, #shift, #structure, #sub, t, #to_a
Constructor Details
#initialize(pattern) ⇒ Pattern
Create a Patten matcher which will match any atom that either matches the input pattern
.
1183 1184 1185 |
# File 'lib/sexp.rb', line 1183 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.
1173 1174 1175 |
# File 'lib/sexp.rb', line 1173 def pattern @pattern end |
Instance Method Details
#==(o) ⇒ Object
:nodoc:
1175 1176 1177 |
# File 'lib/sexp.rb', line 1175 def == o # :nodoc: super && self.pattern == o.pattern end |
#inspect ⇒ Object
:nodoc:
1194 1195 1196 |
# File 'lib/sexp.rb', line 1194 def inspect # :nodoc: "m(%p)" % pattern end |
#pretty_print(q) ⇒ Object
:nodoc:
1198 1199 1200 1201 1202 |
# File 'lib/sexp.rb', line 1198 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
1190 1191 1192 |
# File 'lib/sexp.rb', line 1190 def satisfy? o !o.kind_of?(Sexp) && o.to_s =~ pattern # TODO: question to_s end |