Module: ActiveRecord::Refined::AST::NumericArithmetics
- Defined in:
- lib/active_record/refined/ast.rb
Overview
Arithmetic with the number on the left, imported into the numeric refinements: 20 - :quantity builds what :quantity + 20 builds. Only a column or an expression on the right means a query; anything else goes back to the number through super, so 1 + 2 is 3 inside a block too.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #/(other) ⇒ Object
- #<<(other) ⇒ Object
- #>>(other) ⇒ Object
- #^(other) ⇒ Object
- #|(other) ⇒ Object
Instance Method Details
#&(other) ⇒ Object
363 364 365 366 |
# File 'lib/active_record/refined/ast.rb', line 363 def &(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Bitwise.new(self, :&, other) end |
#*(other) ⇒ Object
353 354 355 356 |
# File 'lib/active_record/refined/ast.rb', line 353 def *(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Arithmetic.new(self, :*, other) end |
#+(other) ⇒ Object
343 344 345 346 |
# File 'lib/active_record/refined/ast.rb', line 343 def +(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Arithmetic.new(self, :+, other) end |
#-(other) ⇒ Object
348 349 350 351 |
# File 'lib/active_record/refined/ast.rb', line 348 def -(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Arithmetic.new(self, :-, other) end |
#/(other) ⇒ Object
358 359 360 361 |
# File 'lib/active_record/refined/ast.rb', line 358 def /(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Arithmetic.new(self, :/, other) end |
#<<(other) ⇒ Object
378 379 380 381 |
# File 'lib/active_record/refined/ast.rb', line 378 def <<(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Bitwise.new(self, :<<, other) end |
#>>(other) ⇒ Object
383 384 385 386 |
# File 'lib/active_record/refined/ast.rb', line 383 def >>(other) return super unless other.is_a?(::Symbol) || other.is_a?(Node) Bitwise.new(self, :>>, other) end |