class Calculator
Constants
- COEFFICIENTS
Attributes
bw[R]
sex[R]
wl[R]
Public Class Methods
new(sex, bodyweight, weight_lifted)
click to toggle source
# File lib/wilks_calc/calculator.rb, line 13 def initialize(sex, bodyweight, weight_lifted) @sex = sex @bw = bodyweight.to_f @wl = weight_lifted.to_f end
Public Instance Methods
calculate()
click to toggle source
# File lib/wilks_calc/calculator.rb, line 19 def calculate (wl * 500 / coeff_calculator).round(2) end
coeff_calculator()
click to toggle source
# File lib/wilks_calc/calculator.rb, line 23 def coeff_calculator() ('A'..'F').to_a.each_with_index.reduce(0) do |memo, (coeff, index)| memo += power(coeff, index) end end
power(coeff, p)
click to toggle source
# File lib/wilks_calc/calculator.rb, line 29 def power(coeff, p) COEFFICIENTS[coeff.to_sym][sex.to_sym] * bw ** p end