Class: Rewrite::ByExample::AnyEntity

Inherits:
EntityMatcher show all
Defined in:
lib/rewrite/by_example/any_entity.rb

Overview

Matches any entity and optionally binds that entity’s value to a name in the unfolded result. AnyEntity.new(‘name’) binds whatever it matches to ‘name’.

Not isomorphic to BindSequence: if you want to match a sequence consisting of exactly one entity and bind that to ‘name’, you need to combine AnyEntity with LengthOne:

LengthOne.new(AnyEntity.new('name))

Instance Attribute Summary

Attributes inherited from EntityMatcher

#predicate

Instance Method Summary collapse

Methods inherited from EntityMatcher

#after_unfold, #fold, #such_that!

Instance Method Details

#to_sObject



24
25
26
# File 'lib/rewrite/by_example/any_entity.rb', line 24

def to_s
  '__'
end

#unfold(sexp) ⇒ Object



20
21
22
# File 'lib/rewrite/by_example/any_entity.rb', line 20

def unfold (sexp)
  {}
end