Module: Ripper::RubyBuilder::Operator
- Included in:
- Ripper::RubyBuilder
- Defined in:
- lib/ripper/ruby_builder/events/operator.rb
Instance Method Summary collapse
- #on_binary(left, operator, right) ⇒ Object
- #on_ifop(condition, left, right) ⇒ Object
- #on_unary(operator, operand) ⇒ Object
Instance Method Details
#on_binary(left, operator, right) ⇒ Object
11 12 13 14 |
# File 'lib/ripper/ruby_builder/events/operator.rb', line 11 def on_binary(left, operator, right) operator = pop_token(:"@#{operator}", :pass => true, :right => right) Ruby::Binary.new(operator, left, right) if operator end |
#on_ifop(condition, left, right) ⇒ Object
16 17 18 19 20 |
# File 'lib/ripper/ruby_builder/events/operator.rb', line 16 def on_ifop(condition, left, right) operators = pop_ternary_operator(:left => condition, :right => left), pop_ternary_operator(:left => left, :right => right) Ruby::IfOp.new(condition, left, right, operators) end |
#on_unary(operator, operand) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/ripper/ruby_builder/events/operator.rb', line 4 def on_unary(operator, operand) operator = pop_unary_operator(:pass => true, :right => operand) # e.g. not(1) ldelim = pop_token(:@lparen, :left => operator) rdelim = pop_token(:@rparen, :left => operator) if ldelim Ruby::Unary.new(operator, operand, ldelim, rdelim) if operator end |