Module: ActiveRecord::Refined::AST::Arithmetics

Included in:
Aggregate, Arithmetic, Bitwise, BitwiseNot, Case, Cast, Column, DatetimeValueFunction, Extract, Function, JsonPath, Operation, Over, Sql, Value
Defined in:
lib/active_record/refined/ast.rb

Overview

Arithmetic builders shared by symbols, qualified columns and expressions. Imported into the Symbol refinement like Predications, so every method must be defined with def.

Instance Method Summary collapse

Instance Method Details

#&(other) ⇒ Object

SQL's bitwise operators. & and | are AND and OR between conditions and are defined there, which is what leaves them free to mean here what SQL means by them. Ruby's precedence puts all six above the comparisons, so :flags & 4 > 0 groups the way it reads.



312
313
314
# File 'lib/active_record/refined/ast.rb', line 312

def &(other)
  Bitwise.new(self, :&, other)
end

#*(other) ⇒ Object



300
301
302
# File 'lib/active_record/refined/ast.rb', line 300

def *(other)
  Arithmetic.new(self, :*, other)
end

#+(other) ⇒ Object



292
293
294
# File 'lib/active_record/refined/ast.rb', line 292

def +(other)
  Arithmetic.new(self, :+, other)
end

#-(other) ⇒ Object



296
297
298
# File 'lib/active_record/refined/ast.rb', line 296

def -(other)
  Arithmetic.new(self, :-, other)
end

#/(other) ⇒ Object



304
305
306
# File 'lib/active_record/refined/ast.rb', line 304

def /(other)
  Arithmetic.new(self, :/, other)
end

#<<(other) ⇒ Object



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

def <<(other)
  Bitwise.new(self, :<<, other)
end

#>>(other) ⇒ Object



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

def >>(other)
  Bitwise.new(self, :>>, other)
end

#^(other) ⇒ Object



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

def ^(other)
  Bitwise.new(self, :^, other)
end

#|(other) ⇒ Object



316
317
318
# File 'lib/active_record/refined/ast.rb', line 316

def |(other)
  Bitwise.new(self, :|, other)
end

#~Object



332
333
334
# File 'lib/active_record/refined/ast.rb', line 332

def ~
  BitwiseNot.new(self)
end