Class: Sexp::Type
Overview
Constant Summary
Constants inherited from Sexp
Instance Attribute Summary collapse
-
#sexp_type ⇒ Object
readonly
Returns the value of attribute sexp_type.
Attributes inherited from Sexp
#comments, #file, #line, #line_max
Instance Method Summary collapse
-
#==(o) ⇒ Object
:nodoc:.
-
#initialize(type) ⇒ Type
constructor
Creates a Matcher which will match any Sexp who’s type is
type
, where a type is the first element in the Sexp. -
#inspect ⇒ Object
:nodoc:.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#satisfy?(o) ⇒ Boolean
Satisfied if the sexp_type of
o
istype
.
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=, #shift, #structure, #sub, t, #to_a, #value
Constructor Details
#initialize(type) ⇒ Type
Creates a Matcher which will match any Sexp who’s type is type
, where a type is the first element in the Sexp.
904 905 906 |
# File 'lib/sexp_matcher.rb', line 904 def initialize type @sexp_type = type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sexp
Instance Attribute Details
#sexp_type ⇒ Object (readonly)
Returns the value of attribute sexp_type.
898 899 900 |
# File 'lib/sexp_matcher.rb', line 898 def sexp_type @sexp_type end |
Instance Method Details
#==(o) ⇒ Object
:nodoc:
908 909 910 |
# File 'lib/sexp_matcher.rb', line 908 def == o # :nodoc: super && self.sexp_type == o.sexp_type end |
#inspect ⇒ Object
:nodoc:
919 920 921 |
# File 'lib/sexp_matcher.rb', line 919 def inspect # :nodoc: "t(%p)" % sexp_type end |
#pretty_print(q) ⇒ Object
:nodoc:
923 924 925 926 927 |
# File 'lib/sexp_matcher.rb', line 923 def pretty_print q # :nodoc: q.group 1, "t(", ")" do q.pp sexp_type end end |
#satisfy?(o) ⇒ Boolean
Satisfied if the sexp_type of o
is type
.
915 916 917 |
# File 'lib/sexp_matcher.rb', line 915 def satisfy? o o.kind_of?(Sexp) && o.sexp_type == sexp_type end |