Class: Sexp::Klass

Inherits:
Pattern show all
Defined in:
lib/sexp_matcher.rb

Overview

Matches any atom that is an instance of the specified class or module.

examples:

s(:lit, 6.28) / s{ q(:lit, k(Float)) }                   #=> [s(:lit, 6.28)]

Constant Summary

Constants inherited from Sexp

UNASSIGNED

Instance Attribute Summary

Attributes inherited from Pattern

#pattern

Attributes inherited from Sexp

#comments, #file, #line, #line_max

Instance Method Summary collapse

Methods inherited from Pattern

#==, #eql?, #hash, #initialize

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, #initialize, 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

This class inherits a constructor from Sexp::Pattern

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sexp

Instance Method Details

#inspectObject

:nodoc:



876
877
878
# File 'lib/sexp_matcher.rb', line 876

def inspect # :nodoc:
  "k(%p)" % pattern
end

#pretty_print(q) ⇒ Object

:nodoc:



880
881
882
883
884
# File 'lib/sexp_matcher.rb', line 880

def pretty_print q # :nodoc:
  q.group 1, "k(", ")" do
    q.pp pattern
  end
end

#satisfy?(o) ⇒ Boolean

Returns:

  • (Boolean)


872
873
874
# File 'lib/sexp_matcher.rb', line 872

def satisfy? o
  o.kind_of? self.pattern
end