Class: Y2R::AST::Ruby::Expressions

Inherits:
Node
  • Object
show all
Defined in:
lib/y2r/ast/ruby.rb

Overview

Expressions =====

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



821
822
823
# File 'lib/y2r/ast/ruby.rb', line 821

def priority
  Priority::ATOMIC
end

#single_line_width_base(context) ⇒ Object



811
812
813
814
815
816
817
818
819
# File 'lib/y2r/ast/ruby.rb', line 811

def single_line_width_base(context)
  if !expressions_have_comments?
    expressions_context = context.with_priority(Priority::NONE)

    1 + list_single_line_width(expressions, 2, expressions_context) + 1
  else
    Float::INFINITY
  end
end

#to_ruby_base(context) ⇒ Object



803
804
805
806
807
808
809
# File 'lib/y2r/ast/ruby.rb', line 803

def to_ruby_base(context)
  if (fits_current_line?(context) && !expressions_have_comments?) || expressions.empty?
    to_ruby_base_single_line(context)
  else
    to_ruby_base_multi_line(context)
  end
end