Module: BMI::CommonRisk

Included in:
JASSO, WHO
Defined in:
lib/bmi/commonrisk.rb

Constant Summary collapse

UPPER_LIMIT =
25
LOWER_LIMIT =
18.5.to_r

Instance Method Summary collapse

Instance Method Details

#normal?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bmi/commonrisk.rb', line 26

def normal?
  (LOWER_LIMIT...UPPER_LIMIT).cover?(@index)
end

#obese?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/bmi/commonrisk.rb', line 18

def obese?
  @index >= 30
end

#overweight?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bmi/commonrisk.rb', line 22

def overweight?
  @index >= UPPER_LIMIT
end

#primeFixnum

Returns:

  • (Fixnum)


35
36
37
# File 'lib/bmi/commonrisk.rb', line 35

def prime
  100 - ((@index / UPPER_LIMIT) * 100)
end

#riskSymbol

Returns:

  • (Symbol)


9
10
11
12
# File 'lib/bmi/commonrisk.rb', line 9

def risk
  _risks.find { |symbol| __send__(:"#{symbol}?") } ||
    raise('must not happen')
end

#underweight?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/bmi/commonrisk.rb', line 30

def underweight?
  @index < LOWER_LIMIT
end

#very_obese?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/bmi/commonrisk.rb', line 14

def very_obese?
  @index >= 35
end