Class: Renalware::Gender

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/values/renalware/gender.rb

Constant Summary collapse

DATA =
{
  "NK" => "Not Known",
  "M" => "Male",
  "F" => "Female",
  "NS" => "Not Specified"
}.freeze
SALUTATIONS =
{
  "NK" => "",
  "M" => "Mr",
  "F" => "Ms",
  "NS" => ""
}.freeze
NHS_DICTIONARY_NUMBERS =
{
  "NK" => 0,
  "M" => 1,
  "F" => 2,
  "NS" => 9
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Gender

Returns a new instance of Gender.



43
44
45
# File 'app/values/renalware/gender.rb', line 43

def initialize(code)
  @code = code && ActiveSupport::StringInquirer.new(code)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'app/values/renalware/gender.rb', line 6

def code
  @code
end

Class Method Details

.allObject



29
30
31
# File 'app/values/renalware/gender.rb', line 29

def self.all
  DATA.map { |code, _| new(code) }
end

.dump(gender) ⇒ Object



39
40
41
# File 'app/values/renalware/gender.rb', line 39

def self.dump(gender)
  gender.to_str
end

.load(raw_string) ⇒ Object



35
36
37
# File 'app/values/renalware/gender.rb', line 35

def self.load(raw_string)
  new(raw_string)
end

Instance Method Details

#nameObject



54
55
56
# File 'app/values/renalware/gender.rb', line 54

def name
  DATA[code]
end

#nhs_dictionary_numberObject



62
63
64
# File 'app/values/renalware/gender.rb', line 62

def nhs_dictionary_number
  NHS_DICTIONARY_NUMBERS[code]
end

#salutationObject



58
59
60
# File 'app/values/renalware/gender.rb', line 58

def salutation
  SALUTATIONS[code]
end

#to_sObject



68
69
70
# File 'app/values/renalware/gender.rb', line 68

def to_s
  code
end

#to_strObject



72
73
74
# File 'app/values/renalware/gender.rb', line 72

def to_str
  code
end