Class: BigDecimal

Inherits:
Object
  • Object
show all
Defined in:
lib/pulo/quantity/numeric_overloads.rb,
lib/pulo/quantity/numeric_overloads.rb,
lib/pulo/quantity/numeric_overloads.rb,
lib/pulo/quantity/numeric_overloads.rb

Overview

Multiplication is a reversal for Quantity * Scalar

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object



186
187
188
189
190
191
192
# File 'lib/pulo/quantity/numeric_overloads.rb', line 186

def *(other)
  if other.is_a?(Pulo::Quantity)
    other*self
  else
    self.old_times(other)
  end
end

#+(other) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/pulo/quantity/numeric_overloads.rb', line 118

def +(other)
  if other.is_a?(Pulo::Dimensionless)
    Pulo::Dimensionless.new(self+other.to_base_unit.value)
  else
    self.old_plus(other)
  end
end

#-(other) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/pulo/quantity/numeric_overloads.rb', line 85

def -(other)
  if other.is_a?(Pulo::Dimensionless)
    Pulo::Dimensionless.new(self-other.to_base_unit.value)
  else
    self.old_minus(other)
  end
end

#/(other) ⇒ Object



152
153
154
155
156
157
158
# File 'lib/pulo/quantity/numeric_overloads.rb', line 152

def /(other)
  if other.is_a?(Pulo::Quantity)
    other.inverse*self
  else
    self.old_div(other)
  end
end

#old_divObject



151
# File 'lib/pulo/quantity/numeric_overloads.rb', line 151

alias :old_div :/

#old_minusObject



84
# File 'lib/pulo/quantity/numeric_overloads.rb', line 84

alias :old_minus :-

#old_plusObject



117
# File 'lib/pulo/quantity/numeric_overloads.rb', line 117

alias :old_plus :+

#old_timesObject



185
# File 'lib/pulo/quantity/numeric_overloads.rb', line 185

alias :old_times :*