Class: Y2R::AST::Ruby::Unless

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



516
517
518
# File 'lib/y2r/ast/ruby.rb', line 516

def priority
  Priority::NONE
end

#single_line_width_base(context) ⇒ Object



503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/y2r/ast/ruby.rb', line 503

def single_line_width_base(context)
  if !self.else && !has_line_breaking_comment?
    inner_context = context.with_priority(priority)

    then_width      = self.then.single_line_width(inner_context)
    condition_width = condition.single_line_width(inner_context)

    then_width + 8 + condition_width
  else
    Float::INFINITY
  end
end

#to_ruby_base(context) ⇒ Object



495
496
497
498
499
500
501
# File 'lib/y2r/ast/ruby.rb', line 495

def to_ruby_base(context)
  if fits_current_line?(context) && !has_line_breaking_comment?
    to_ruby_base_single_line(context)
  else
    to_ruby_base_multi_line(context)
  end
end