Class: Numeric
Instance Method Summary collapse
- #add_percent(percent) ⇒ Object (also: #markup_by_percent)
- #length ⇒ Object (also: #digits)
- #subtract_percent(percent) ⇒ Object (also: #percentage_off)
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 |
#length ⇒ Object Also known as: digits
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 |