Class: Synthra::Types::HealthMedical::Bmi

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/health_medical/medical.rb

Overview

Bmi type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



71
72
73
# File 'lib/synthra/types/health_medical/medical.rb', line 71

def generate_edge(rng, context, args)
  [15.0, 40.0, 18.5, 25.0].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



75
76
77
# File 'lib/synthra/types/health_medical/medical.rb', line 75

def generate_invalid(rng, context, args)
  [nil, "not a number", -1.0, 50.0, [], {}].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ Float

Generate random BMI

Parameters:

Options Hash (args):

  • :range (Range)

    BMI range (default: 15.0..40.0)

  • :min (Float)

    minimum BMI (default: 15.0)

  • :max (Float)

    maximum BMI (default: 40.0)

Returns:

  • (Float)

    generated BMI value



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/synthra/types/health_medical/medical.rb', line 59

def generate_random(rng, context, args)
  if args[:range].is_a?(Range)
    min = args[:range].min
    max = args[:range].max
  else
    min = args[:min] || 15.0
    max = args[:max] || 40.0
  end
  value = rng.rand * (max - min) + min
  value.round(1)
end