Class: Atomy::Code::Pattern::QuasiQuote::Walker
- Defined in:
- lib/atomy/code/pattern/quasi_quote.rb
Direct Known Subclasses
Instance Method Summary collapse
- #go(x) ⇒ Object
-
#initialize ⇒ Walker
constructor
A new instance of Walker.
- #unquote(_) ⇒ Object
- #visit_quasiquote(qq) ⇒ Object
- #visit_unquote(x) ⇒ Object
Constructor Details
#initialize ⇒ Walker
Returns a new instance of Walker.
29 30 31 |
# File 'lib/atomy/code/pattern/quasi_quote.rb', line 29 def initialize @depth = 0 end |
Instance Method Details
#go(x) ⇒ Object
33 34 35 |
# File 'lib/atomy/code/pattern/quasi_quote.rb', line 33 def go(x) x.accept(self) end |
#unquote(_) ⇒ Object
56 57 58 |
# File 'lib/atomy/code/pattern/quasi_quote.rb', line 56 def unquote(_) raise NotImplementedError end |
#visit_quasiquote(qq) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/atomy/code/pattern/quasi_quote.rb', line 37 def visit_quasiquote(qq) @depth += 1 visit(qq) ensure @depth -= 1 end |
#visit_unquote(x) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/atomy/code/pattern/quasi_quote.rb', line 44 def visit_unquote(x) @depth -= 1 if @depth == 0 unquote(x) else visit(x) end ensure @depth += 1 end |