Class: ActiveRecord::Refined::AST::Arithmetic

Inherits:
Node
  • Object
show all
Includes:
Arithmetics, Predications
Defined in:
lib/active_record/refined/ast.rb

Overview

Arithmetic on columns and expressions. Ruby's precedence puts these above the comparison operators, so :price * :quantity > 100 groups the way it reads.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Arithmetics

#&, #*, #+, #-, #/, #<<, #>>, #^, #|, #~

Methods included from Predications

#!=, #!~, #<, #<=, #==, #=~, #>, #>=, #between?, #bury, #casecmp?, #contains?, #dig, #dig_json, #distinct_from?, #end_with?, #false?, #ilike?, #in?, #include?, #intersect?, #key?, #like?, #member?, #not_between?, #not_distinct_from?, #not_false?, #not_ilike?, #not_in?, #not_like?, #not_null?, #not_true?, #null?, #start_with?, #subset?, #superset?, #true?, #when

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(left, operator, right) ⇒ Arithmetic

Returns a new instance of Arithmetic.



704
705
706
707
708
# File 'lib/active_record/refined/ast.rb', line 704

def initialize(left, operator, right)
  @left = left
  @operator = operator
  @right = right
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



702
703
704
# File 'lib/active_record/refined/ast.rb', line 702

def left
  @left
end

#operatorObject (readonly)

Returns the value of attribute operator.



702
703
704
# File 'lib/active_record/refined/ast.rb', line 702

def operator
  @operator
end

#rightObject (readonly)

Returns the value of attribute right.



702
703
704
# File 'lib/active_record/refined/ast.rb', line 702

def right
  @right
end

Instance Method Details

#to_arel(table, model) ⇒ Object



710
711
712
713
# File 'lib/active_record/refined/ast.rb', line 710

def to_arel(table, model)
  to_arel_operand(left, table, model).
    public_send(operator, to_arel_operand(right, table, model))
end