Class: Y2R::AST::Ruby::Assignment

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

#ensure_separated, #has_comment?, #hates_to_stand_alone?, #single_line_width, #to_ruby

Instance Method Details

#ends_with_comment?Boolean

Returns:

  • (Boolean)


874
875
876
# File 'lib/y2r/ast/ruby.rb', line 874

def ends_with_comment?
  comment_after || rhs.ends_with_comment?
end

#pass_trailer?Boolean

Returns:

  • (Boolean)


878
879
880
# File 'lib/y2r/ast/ruby.rb', line 878

def pass_trailer?
  true
end

#priorityObject



866
867
868
# File 'lib/y2r/ast/ruby.rb', line 866

def priority
  Priority::ASSIGNMENT
end

#single_line_width_base(context) ⇒ Object



853
854
855
856
857
858
859
860
861
862
863
864
# File 'lib/y2r/ast/ruby.rb', line 853

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

    lhs_width = lhs.single_line_width(inner_context)
    rhs_width = rhs.single_line_width(inner_context)

    lhs_width + 3 + rhs_width
  else
    Float::INFINITY
  end
end

#starts_with_comment?Boolean

Returns:

  • (Boolean)


870
871
872
# File 'lib/y2r/ast/ruby.rb', line 870

def starts_with_comment?
  comment_before || lhs.starts_with_comment?
end

#to_ruby_base(context) ⇒ Object



845
846
847
848
849
850
851
# File 'lib/y2r/ast/ruby.rb', line 845

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