Class: Delorean::IfElsifElse
- Defined in:
- lib/delorean/nodes.rb
Instance Method Summary collapse
Instance Method Details
#check(context) ⇒ Object
663 664 665 666 667 668 669 670 671 672 673 |
# File 'lib/delorean/nodes.rb', line 663 def check(context, *) vc = v.check(context) e1c = e1.check(context) e2c = e2.check(context) elsifs_check = elsifs.elements.map do |node| [node.v.check(context), node.e1.check(context)] end.flatten vc + e1c + e2c + elsifs_check end |
#rewrite(context) ⇒ Object
675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'lib/delorean/nodes.rb', line 675 def rewrite(context) elsifs_string = elsifs.elements.map do |node| "elsif (#{node.v.rewrite(context)}) (#{node.e1.rewrite(context)})" end.join("\n") "if (#{v.rewrite(context)}) (#{e1.rewrite(context)}) #{elsifs_string} else (#{e2.rewrite(context)}) end" end |