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.



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

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

#*(other) ⇒ Object



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

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

#+(other) ⇒ Object



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

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

#-(other) ⇒ Object



267
268
269
# File 'lib/active_record/refined/ast.rb', line 267

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

#/(other) ⇒ Object



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

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

#<<(other) ⇒ Object



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

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

#>>(other) ⇒ Object



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

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

#^(other) ⇒ Object



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

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

#|(other) ⇒ Object



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

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

#~Object



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

def ~
  BitwiseNot.new(self)
end