Sha256: 6f351af6266af583f4ee42ba16ea4e3c1858fb94568309ade7893a15c2801aa4

Contents?: true

Size: 462 Bytes

Versions: 19

Compression:

Stored size: 462 Bytes

Contents

require "attr_extras"

module Renalware
  # Value object representing Body Mass Index. Accepts only meters and kg
  #
  # Example usage:
  #   bmi = Renalware::BMI.new(height: 1.80, weight: 180)
  #   bmi.to_f # => 55.6
  #   bmi.to_s # => "55.6"
  #
  class BMI
    pattr_initialize [:weight!, :height!]
    delegate :to_s, to: :to_f

    def to_f
      return unless weight && height && height > 0
      ((weight / height) / height).round(1)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/values/renalware/bmi.rb
renalware-core-2.0.15 app/values/renalware/bmi.rb
renalware-core-2.0.14 app/values/renalware/bmi.rb
renalware-core-2.0.13 app/values/renalware/bmi.rb
renalware-core-2.0.12 app/values/renalware/bmi.rb
renalware-core-2.0.11 app/values/renalware/bmi.rb
renalware-core-2.0.9 app/values/renalware/bmi.rb
renalware-core-2.0.8 app/values/renalware/bmi.rb
renalware-core-2.0.7 app/values/renalware/bmi.rb
renalware-core-2.0.5 app/values/renalware/bmi.rb
renalware-core-2.0.4 app/values/renalware/bmi.rb
renalware-core-2.0.3 app/values/renalware/bmi.rb
renalware-core-2.0.2 app/values/renalware/bmi.rb
renalware-core-2.0.1 app/values/renalware/bmi.rb
renalware-core-2.0.0 app/values/renalware/bmi.rb
renalware-core-2.0.0.pre.rc13 app/values/renalware/bmi.rb
renalware-core-2.0.0.pre.rc11 app/values/renalware/bmi.rb
renalware-core-2.0.0.pre.rc10 app/values/renalware/bmi.rb
renalware-core-2.0.0.pre.rc9 app/values/renalware/bmi.rb