Class: Synthra::Types::HealthMedical::BloodType

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

Overview

BloodType type

Constant Summary collapse

BLOOD_TYPES =

Available blood type identifiers

Standard ABO blood group system with Rh factor.

Returns:

  • (Array<String>)

    list of blood type strings

["A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"].freeze

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



38
39
40
# File 'lib/synthra/types/health_medical/medical.rb', line 38

def generate_edge(rng, context, args)
  ["", "O+", "AB-"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



42
43
44
# File 'lib/synthra/types/health_medical/medical.rb', line 42

def generate_invalid(rng, context, args)
  [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ String

Generate random blood type

Parameters:

Returns:

  • (String)

    generated blood type



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/synthra/types/health_medical/medical.rb', line 23

def generate_random(rng, context, args)
  # Try Faker first
  adapter = faker_adapter(context)
  if adapter
    adapter.blood_type

  else
    Faker::Blood.type
  end

rescue StandardError
  rng.sample(BLOOD_TYPES)
end