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

Included in:
Aggregate, Arithmetic, Bitwise, BitwiseNot, Case, Cast, Column, DatetimeValueFunction, Extract, Function, JsonPath, Over, 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.



272
273
274
# File 'lib/active_record/refined/ast.rb', line 272

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

#*(other) ⇒ Object



260
261
262
# File 'lib/active_record/refined/ast.rb', line 260

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

#+(other) ⇒ Object



252
253
254
# File 'lib/active_record/refined/ast.rb', line 252

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

#-(other) ⇒ Object



256
257
258
# File 'lib/active_record/refined/ast.rb', line 256

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

#/(other) ⇒ Object



264
265
266
# File 'lib/active_record/refined/ast.rb', line 264

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

#<<(other) ⇒ Object



284
285
286
# File 'lib/active_record/refined/ast.rb', line 284

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

#>>(other) ⇒ Object



288
289
290
# File 'lib/active_record/refined/ast.rb', line 288

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

#^(other) ⇒ Object



280
281
282
# File 'lib/active_record/refined/ast.rb', line 280

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

#|(other) ⇒ Object



276
277
278
# File 'lib/active_record/refined/ast.rb', line 276

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

#~Object



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

def ~
  BitwiseNot.new(self)
end