Class: Y2R::AST::Ruby::While
- Inherits:
-
Node
- Object
- OpenStruct
- Node
- Y2R::AST::Ruby::While
show all
- Defined in:
- lib/y2r/ast/ruby.rb
Constant Summary
Constants inherited
from Node
Node::INDENT_STEP
Instance Method Summary
collapse
Methods inherited from Node
#ends_with_comment?, #ensure_separated, #has_comment?, #hates_to_stand_alone?, #pass_trailer?, #single_line_width, #starts_with_comment?, #to_ruby
Instance Method Details
#priority ⇒ Object
658
659
660
|
# File 'lib/y2r/ast/ruby.rb', line 658
def priority
Priority::NONE
end
|
#single_line_width_base(context) ⇒ Object
654
655
656
|
# File 'lib/y2r/ast/ruby.rb', line 654
def single_line_width_base(context)
Float::INFINITY
end
|
#to_ruby_base(context) ⇒ Object
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
|
# File 'lib/y2r/ast/ruby.rb', line 637
def to_ruby_base(context)
inner_context = context.with_priority(priority)
if !body.is_a?(Begin)
combine do |parts|
parts << ("while", condition, inner_context)
parts << indented(body, inner_context)
parts << "end"
end
else
body_code = body.to_ruby(inner_context)
condition_code = condition.to_ruby(inner_context)
"#{body_code} while #{condition_code}"
end
end
|