Class: Grammar::Ruby::Code::List
Direct Known Subclasses
And, Assign, Begin, Binary, Blocked, Call, Conditional, Conditional::Question, Def, Or, Steps
Constant Summary
False, FalseTerminator, Implicit, Nil, Self, True
Instance Method Summary
collapse
[], #_and, #_assign, #_classname, #_code_self, #_data, #_def, #_dot, #_else, #_ensure, #_equal, #_immediate, #_inspect, #_locals, #_mid, #_not, #_or, #_question, #_rand, #_rcond, #_rescue, #_ror, #_rstep, #_splat, #_step, #_to_block, #_unless, #_until, #_while, #method_missing
Constructor Details
#initialize(operands) ⇒ List
Returns a new instance of List.
434
435
436
|
# File 'lib/grammar/ruby/code.rb', line 434
def initialize(operands)
@operands = operands
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Grammar::Ruby::Code
Instance Method Details
#_always ⇒ Object
495
496
497
|
# File 'lib/grammar/ruby/code.rb', line 495
def _always
false
end
|
#_codes ⇒ Object
437
438
439
|
# File 'lib/grammar/ruby/code.rb', line 437
def _codes
@operands
end
|
#_lines(text, indent = 0, op = nil, maxlen = 72) ⇒ Object
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
# File 'lib/grammar/ruby/code.rb', line 440
def _lines(text, indent=0, op=nil, maxlen=72)
delim = _operator
delim0 = _operator0
paren = _paren(op)
if paren
text.last << ?\(
indent += 1
end
if @operands.empty?
last = text.last
last << ?\) if paren
return last
end
op = (delim==", ") ? nil : delim
delim ||= ""
len = text[-2]+text.last.size-delim0.size-delim.size
n = text.size
needdelim0 = text.last.empty?
single = true
@operands.each_with_index { |operand, i|
text << indent << "" unless text.last.empty?
if operand._lines(text, indent, op, maxlen)
len += delim.size+delim0.size+text.last.size
else
single = nil
end
text.last.concat(delim) unless i==@operands.size-1
}
if single && len<=maxlen
last = text[n-1]
i = n+1
while i<text.size
last.concat(delim0) if needdelim0
last.concat(text[i])
needdelim0 = true
i += 2
end
text.slice!(n, i-n)
last << ?\) if paren
last
else
text << (indent-1) << ")" if paren
nil
end
end
|
#_never ⇒ Object
498
499
500
|
# File 'lib/grammar/ruby/code.rb', line 498
def _never
false
end
|
#_operator ⇒ Object
486
487
488
|
# File 'lib/grammar/ruby/code.rb', line 486
def _operator
", "
end
|
#_operator0 ⇒ Object
489
490
491
|
# File 'lib/grammar/ruby/code.rb', line 489
def _operator0
""
end
|
#_paren(op) ⇒ Object
492
493
494
|
# File 'lib/grammar/ruby/code.rb', line 492
def _paren(op)
op
end
|