Class: Grammar::Ruby::Code::Or
- Inherits:
-
List
- Object
- Grammar::Ruby::Code
- List
- Grammar::Ruby::Code::Or
- Defined in:
- lib/grammar/ruby/code.rb
Constant Summary
Constants inherited from Grammar::Ruby::Code
False, FalseTerminator, Implicit, Nil, Self, True
Class Method Summary collapse
Instance Method Summary collapse
- #_always ⇒ Object
-
#_and ⇒ Object
:yield:.
- #_mid(before) ⇒ Object
- #_operator ⇒ Object
-
#_or ⇒ Object
:yield:.
- #_ror(before) ⇒ Object
Methods inherited from List
#_codes, #_lines, #_never, #_operator0, #_paren, #initialize
Methods inherited from Grammar::Ruby::Code
[], #_assign, #_classname, #_code_self, #_codes, #_data, #_def, #_dot, #_else, #_ensure, #_equal, #_immediate, #_inspect, #_lines, #_locals, #_never, #_not, #_question, #_rand, #_rcond, #_rescue, #_rstep, #_splat, #_step, #_to_block, #_unless, #_until, #_while, #initialize, #method_missing
Constructor Details
This class inherits a constructor from Grammar::Ruby::Code::List
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Grammar::Ruby::Code
Class Method Details
.new(operands) ⇒ Object
572 573 574 |
# File 'lib/grammar/ruby/code.rb', line 572 def self.new(operands) (operands.size==1) ? operands[0] : super end |
Instance Method Details
#_always ⇒ Object
578 579 580 |
# File 'lib/grammar/ruby/code.rb', line 578 def _always @operands.last._always end |
#_and ⇒ Object
:yield:
590 591 592 593 594 595 596 597 |
# File 'lib/grammar/ruby/code.rb', line 590 def _and # :yield: after = yield last = @operands.last (!last._never||after._always) ? And.new(after._rand(operands = [self])) : last._unless( (@operands.size==2) ? @operands.first : (@operands.pop;self), after) end |
#_mid(before) ⇒ Object
598 599 600 601 602 603 604 605 |
# File 'lib/grammar/ruby/code.rb', line 598 def _mid(before) @operands.pop._mid(@operands) if @operands.size==1 @operands.first._mid(before) else before << self end end |
#_operator ⇒ Object
575 576 577 |
# File 'lib/grammar/ruby/code.rb', line 575 def _operator " || " end |
#_or ⇒ Object
:yield:
581 582 583 584 |
# File 'lib/grammar/ruby/code.rb', line 581 def _or # :yield: _always ? self : (yield._ror(@operands); self) end |
#_ror(before) ⇒ Object
585 586 587 588 589 |
# File 'lib/grammar/ruby/code.rb', line 585 def _ror(before) @operands[0] = before.pop._step(@operands[0]) if before.last._never before.concat(@operands) end |