Class: ActiveRecord::Refined::AST::Arithmetic
- 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
-
#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, model) ⇒ Object
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
Constructor Details
#initialize(left, operator, right) ⇒ Arithmetic
Returns a new instance of Arithmetic.
708 709 710 711 712 |
# File 'lib/active_record/refined/ast.rb', line 708 def initialize(left, operator, right) @left = left @operator = operator @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
706 707 708 |
# File 'lib/active_record/refined/ast.rb', line 706 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
706 707 708 |
# File 'lib/active_record/refined/ast.rb', line 706 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
706 707 708 |
# File 'lib/active_record/refined/ast.rb', line 706 def right @right end |
Instance Method Details
#to_arel(table, model) ⇒ Object
714 715 716 717 |
# File 'lib/active_record/refined/ast.rb', line 714 def to_arel(table, model) to_arel_operand(left, table, model). public_send(operator, to_arel_operand(right, table, model)) end |