Class: Numeric

Inherits:
Object show all
Defined in:
lib/finishing_moves/numeric.rb

Instance Method Summary collapse

Instance Method Details

#add_percent(percent) ⇒ Object Also known as: markup_by_percent



12
13
14
# File 'lib/finishing_moves/numeric.rb', line 12

def add_percent(percent)
  self.to_f + ( self.to_f * ( percent.to_f / 100.0 ) )
end

#lengthObject Also known as: digits

Raises:

  • (ArgumentError)


2
3
4
# File 'lib/finishing_moves/numeric.rb', line 2

def length
  raise ArgumentError.new("Cannot get length: \"#{self}\" is not an integer")
end

#subtract_percent(percent) ⇒ Object Also known as: percentage_off



7
8
9
# File 'lib/finishing_moves/numeric.rb', line 7

def subtract_percent(percent)
  self.to_f * ( ( 100.0 - percent.to_f ) / 100.0 )
end