Class: Grammar::Ruby::Code::Unary

Inherits:
Grammar::Ruby::Code show all
Defined in:
lib/grammar/ruby/code.rb

Direct Known Subclasses

Dot, Not

Constant Summary

Constants inherited from Grammar::Ruby::Code

False, FalseTerminator, Implicit, Nil, Self, True

Instance Method Summary collapse

Methods inherited from Grammar::Ruby::Code

[], #_and, #_assign, #_classname, #_code_self, #_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(operator, operand) ⇒ Unary

Returns a new instance of Unary.



366
367
368
369
# File 'lib/grammar/ruby/code.rb', line 366

def initialize(operator, operand)
    @operator = operator
    @operand = operand
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Grammar::Ruby::Code

Instance Method Details

#_alwaysObject



379
380
381
# File 'lib/grammar/ruby/code.rb', line 379

def _always
    false
end

#_codesObject



370
371
372
# File 'lib/grammar/ruby/code.rb', line 370

def _codes
    [@operand]
end

#_dataObject



373
374
375
# File 'lib/grammar/ruby/code.rb', line 373

def _data
    @operator
end

#_lines(text, indent = 0, op = nil, maxlen = 72) ⇒ Object



385
386
387
388
# File 'lib/grammar/ruby/code.rb', line 385

def _lines(text, indent=0, op=nil, maxlen=72)
    text.last.concat(_operator)
    @operand._lines(text, indent+1, op, maxlen)
end

#_neverObject



382
383
384
# File 'lib/grammar/ruby/code.rb', line 382

def _never
    false
end

#_operatorObject



376
377
378
# File 'lib/grammar/ruby/code.rb', line 376

def _operator
    @operator
end