Class: Grammar::Ruby::Code::Binary

Inherits:
List show all
Defined in:
lib/grammar/ruby/code.rb

Constant Summary

Constants inherited from Grammar::Ruby::Code

False, FalseTerminator, Implicit, Nil, Self, True

Instance Method Summary collapse

Methods inherited from List

#_always, #_codes, #_lines, #_never, #_operator0, #_paren

Methods inherited from Grammar::Ruby::Code

[], #_always, #_and, #_assign, #_classname, #_code_self, #_codes, #_def, #_dot, #_else, #_ensure, #_equal, #_immediate, #_inspect, #_lines, #_locals, #_mid, #_never, #_not, #_or, #_question, #_rand, #_rcond, #_rescue, #_ror, #_rstep, #_splat, #_step, #_to_block, #_unless, #_until, #_while

Constructor Details

#initialize(operator, *operands) ⇒ Binary

Returns a new instance of Binary.



503
504
505
506
# File 'lib/grammar/ruby/code.rb', line 503

def initialize(operator, *operands)
    @operator = operator
    @operands = operands
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



513
514
515
516
517
518
519
520
# File 'lib/grammar/ruby/code.rb', line 513

def method_missing(method, *args, &block)
    if method.equal?(@operator) && !block
        @operands.concat(args)
        self
    else
        super
    end
end

Instance Method Details

#_dataObject



507
508
509
# File 'lib/grammar/ruby/code.rb', line 507

def _data
    @operator
end

#_operatorObject



510
511
512
# File 'lib/grammar/ruby/code.rb', line 510

def _operator
    @operator
end