Class: TEALrb::Rewriters::AssignRewriter
- Defined in:
- lib/tealrb/rewriters.rb
Instance Attribute Summary
Attributes inherited from Rewriter
Instance Method Summary collapse
- #on_gvar(node) ⇒ Object
- #on_gvasgn(node) ⇒ Object
- #on_ivar(node) ⇒ Object
- #on_ivasgn(node) ⇒ Object
- #on_lvar(node) ⇒ Object
- #on_lvasgn(node) ⇒ Object
Methods inherited from Rewriter
Instance Method Details
#on_gvar(node) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/tealrb/rewriters.rb', line 73 def on_gvar(node) unless RuboCop::Cop::Style::GlobalVars::BUILT_IN_VARS.include? node.loc.name.source.to_sym var_name = node.loc.name.source[1..] replace(node.loc.name, "@scratch[:#{var_name}]") end super end |
#on_gvasgn(node) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/tealrb/rewriters.rb', line 64 def on_gvasgn(node) unless RuboCop::Cop::Style::GlobalVars::BUILT_IN_VARS.include? node.loc.name.source.to_sym var_name = node.loc.name.source[1..] replace(node.loc.name, "@scratch[:#{var_name}]") end super end |
#on_ivar(node) ⇒ Object
59 60 61 62 |
# File 'lib/tealrb/rewriters.rb', line 59 def on_ivar(node) insert_after(node.loc.name, '.call') super end |
#on_ivasgn(node) ⇒ Object
54 55 56 57 |
# File 'lib/tealrb/rewriters.rb', line 54 def on_ivasgn(node) wrap(node.children[1].source_range, '-> {', ' }') super end |
#on_lvar(node) ⇒ Object
49 50 51 52 |
# File 'lib/tealrb/rewriters.rb', line 49 def on_lvar(node) insert_after(node.loc.name, '.call') super end |
#on_lvasgn(node) ⇒ Object
44 45 46 47 |
# File 'lib/tealrb/rewriters.rb', line 44 def on_lvasgn(node) wrap(node.children[1].source_range, '-> {', '}') super end |