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

Inherits:
Node
  • Object
show all
Includes:
Aggregations, 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 Aggregations

#average, #count, #maximum, #minimum, #sum

Methods included from Arithmetics

#*, #+, #-, #/

Methods included from Predications

#!=, #!~, #<, #<=, #==, #=~, #>, #>=, #between?, #casecmp?, #distinct_from?, #end_with?, #ilike?, #in?, #include?, #intersect?, #like?, #member?, #not_between?, #not_distinct_from?, #not_ilike?, #not_in?, #not_like?, #not_null?, #null?, #start_with?, #subset?, #superset?

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(left, operator, right) ⇒ Arithmetic

Returns a new instance of Arithmetic.



323
324
325
326
327
# File 'lib/active_record/refined/ast.rb', line 323

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

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



321
322
323
# File 'lib/active_record/refined/ast.rb', line 321

def left
  @left
end

#operatorObject (readonly)

Returns the value of attribute operator.



321
322
323
# File 'lib/active_record/refined/ast.rb', line 321

def operator
  @operator
end

#rightObject (readonly)

Returns the value of attribute right.



321
322
323
# File 'lib/active_record/refined/ast.rb', line 321

def right
  @right
end

Instance Method Details

#to_arel(table) ⇒ Object



329
330
331
332
# File 'lib/active_record/refined/ast.rb', line 329

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