Class: TEALrb::Rewriters::InlineIfRewriter
- Inherits:
-
Rewriter
- Object
- Parser::TreeRewriter
- Rewriter
- TEALrb::Rewriters::InlineIfRewriter
- Defined in:
- lib/tealrb/rewriters.rb
Instance Attribute Summary
Attributes inherited from Rewriter
Instance Method Summary collapse
Methods inherited from Rewriter
Instance Method Details
#on_if(node) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/tealrb/rewriters.rb', line 182 def on_if(node) unless node.loc.respond_to? :else conditional = node.children[0].source if_blk = if node.keyword == 'unless' node.children[2].source conditional = "!(#{conditional})" else node.children[1].source end replace(node.loc.expression, "if(#{conditional});#{if_blk};end") end super end |