class MotionKit::Calculator
Attributes
constant[RW]
factor[RW]
Public Class Methods
memo()
click to toggle source
# File lib/motion-kit/calculator/calculator.rb, line 6 def self.memo @memo ||= {} end
new(amount)
click to toggle source
# File lib/motion-kit/calculator/calculator.rb, line 15 def initialize(amount) location = amount.index '%' if location self.factor = amount.slice(0, location).to_f / 100.0 location += 1 else self.factor = 0 location = 0 end self.constant = amount.slice(location, amount.size).to_f end
scan(amount)
click to toggle source
# File lib/motion-kit/calculator/calculator.rb, line 10 def self.scan(amount) amount = amount.gsub(' ', '') Calculator.memo[amount] ||= Calculator.new(amount) end