Class: Y2R::AST::Ruby::Until

Inherits:
Node
  • Object
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

#priorityObject



685
686
687
# File 'lib/y2r/ast/ruby.rb', line 685

def priority
  Priority::NONE
end

#single_line_width_base(context) ⇒ Object



681
682
683
# File 'lib/y2r/ast/ruby.rb', line 681

def single_line_width_base(context)
  Float::INFINITY   # always multiline
end

#to_ruby_base(context) ⇒ Object



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/y2r/ast/ruby.rb', line 664

def to_ruby_base(context)
  inner_context = context.with_priority(priority)

  if !body.is_a?(Begin)
    combine do |parts|
      parts << header("until", 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} until #{condition_code}"
  end
end