Class: Y2R::AST::Ruby::Literal
- Inherits:
-
Node
- Object
- OpenStruct
- Node
- Y2R::AST::Ruby::Literal
show all
- Defined in:
- lib/y2r/ast/ruby.rb
Overview
Constant Summary
Constants inherited
from Node
Node::INDENT_STEP
Instance Method Summary
collapse
Methods inherited from Node
#ends_with_comment?, #ensure_separated, #has_comment?, #pass_trailer?, #single_line_width, #starts_with_comment?, #to_ruby
Instance Method Details
#hates_to_stand_alone? ⇒ Boolean
1499
1500
1501
1502
1503
1504
1505
|
# File 'lib/y2r/ast/ruby.rb', line 1499
def hates_to_stand_alone?
if value.is_a?(String) || value.is_a?(Symbol)
value.size <= 16
else
true
end
end
|
#priority ⇒ Object
1491
1492
1493
1494
1495
1496
1497
|
# File 'lib/y2r/ast/ruby.rb', line 1491
def priority
if is_long_multi_line_string?
Priority::ADD
else
Priority::ATOMIC
end
end
|
#single_line_width_base(context) ⇒ Object
1483
1484
1485
1486
1487
1488
1489
|
# File 'lib/y2r/ast/ruby.rb', line 1483
def single_line_width_base(context)
if is_long_multi_line_string?
Float::INFINITY
else
value.inspect.size
end
end
|
#to_ruby_base(context) ⇒ Object
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
|
# File 'lib/y2r/ast/ruby.rb', line 1467
def to_ruby_base(context)
if is_long_multi_line_string?
combine do |parts|
lines = value.lines.to_a
parts << "#{lines.first.inspect} +"
lines[1..-2].each do |line|
parts << indent("#{line.inspect} +")
end
parts << indent("#{lines.last.inspect}")
end
else
value.inspect
end
end
|