Class: ActiveRecord::Refined::AST::Arithmetic
- 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
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
-
#initialize(left, operator, right) ⇒ Arithmetic
constructor
A new instance of Arithmetic.
- #to_arel(table) ⇒ Object
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
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
#left ⇒ Object (readonly)
Returns the value of attribute left.
321 322 323 |
# File 'lib/active_record/refined/ast.rb', line 321 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
321 322 323 |
# File 'lib/active_record/refined/ast.rb', line 321 def operator @operator end |
#right ⇒ Object (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 |