Class: Rewrite::ByExample::SymbolEntity
- Inherits:
-
EntityMatcher
- Object
- EntityMatcher
- Rewrite::ByExample::SymbolEntity
- Defined in:
- lib/rewrite/by_example/symbol_entity.rb
Overview
Matches a specific symbol: SymbolEntity.new(:foo) matches :foo.
Note that this is not the same thing as matching the use of a symbol in Ruby code, because a literal symbol in Ruby is actually represented as:
s(:lit, :foo)
Instance Attribute Summary collapse
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Attributes inherited from EntityMatcher
Instance Method Summary collapse
- #fold(enum_of_bindings) ⇒ Object
-
#initialize(symbol) ⇒ SymbolEntity
constructor
A new instance of SymbolEntity.
- #to_s ⇒ Object
- #unfold(sexp) ⇒ Object
Methods inherited from EntityMatcher
Constructor Details
#initialize(symbol) ⇒ SymbolEntity
Returns a new instance of SymbolEntity.
17 18 19 |
# File 'lib/rewrite/by_example/symbol_entity.rb', line 17 def initialize(symbol) self.symbol = symbol end |
Instance Attribute Details
#symbol ⇒ Object
Returns the value of attribute symbol.
15 16 17 |
# File 'lib/rewrite/by_example/symbol_entity.rb', line 15 def symbol @symbol end |
Instance Method Details
#fold(enum_of_bindings) ⇒ Object
25 26 27 |
# File 'lib/rewrite/by_example/symbol_entity.rb', line 25 def fold (enum_of_bindings) self.symbol end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/rewrite/by_example/symbol_entity.rb', line 29 def to_s ":#{self.symbol.to_s}" end |
#unfold(sexp) ⇒ Object
21 22 23 |
# File 'lib/rewrite/by_example/symbol_entity.rb', line 21 def unfold (sexp) {} if self.symbol == sexp end |