Module: Measured::Arithmetic

Included in:
Measurable
Defined in:
lib/measured/arithmetic.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object



10
11
12
# File 'lib/measured/arithmetic.rb', line 10

def *(other)
  arithmetic_operation(other, :*)
end

#+(other) ⇒ Object



2
3
4
# File 'lib/measured/arithmetic.rb', line 2

def +(other)
  arithmetic_operation(other, :+)
end

#-(other) ⇒ Object



6
7
8
# File 'lib/measured/arithmetic.rb', line 6

def -(other)
  arithmetic_operation(other, :-)
end

#-@Object



18
19
20
# File 'lib/measured/arithmetic.rb', line 18

def -@
  self.class.new(-self.value, self.unit)
end

#/(other) ⇒ Object



14
15
16
# File 'lib/measured/arithmetic.rb', line 14

def /(other)
  arithmetic_operation(other, :/)
end

#coerce(other) ⇒ Object



22
23
24
# File 'lib/measured/arithmetic.rb', line 22

def coerce(other)
  [self, other]
end