Class: Y2R::AST::Ruby::ConstAccess

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, #to_ruby

Instance Method Details

#priorityObject



1395
1396
1397
# File 'lib/y2r/ast/ruby.rb', line 1395

def priority
  Priority::ATOMIC
end

#single_line_width_base(context) ⇒ Object



1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
# File 'lib/y2r/ast/ruby.rb', line 1381

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

      receiver.single_line_width(receiver_context) + 2 + name.size
    else
      Float::INFINITY
    end
  else
    name.size
  end
end

#starts_with_comment?Boolean

Returns:

  • (Boolean)


1399
1400
1401
# File 'lib/y2r/ast/ruby.rb', line 1399

def starts_with_comment?
  comment_before || (receiver && receiver.starts_with_comment?)
end

#to_ruby_base(context) ⇒ Object



1373
1374
1375
1376
1377
1378
1379
# File 'lib/y2r/ast/ruby.rb', line 1373

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