Class: Y2R::AST::Ruby::Case

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



571
572
573
# File 'lib/y2r/ast/ruby.rb', line 571

def priority
  Priority::NONE
end

#single_line_width_base(context) ⇒ Object



567
568
569
# File 'lib/y2r/ast/ruby.rb', line 567

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

#to_ruby_base(context) ⇒ Object



554
555
556
557
558
559
560
561
562
563
564
565
# File 'lib/y2r/ast/ruby.rb', line 554

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

  combine do |parts|
    parts << header("case", expression, inner_context)
    whens.each do |whem|
      parts << indented(whem, inner_context)
    end
    parts << indented(self.else, inner_context) if self.else
    parts << "end"
  end
end