Class: Renalware::Gender
- Inherits:
-
Object
- Object
- Renalware::Gender
- 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
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code) ⇒ Gender
constructor
A new instance of Gender.
- #name ⇒ Object
- #nhs_dictionary_number ⇒ Object
- #salutation ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
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
#code ⇒ Object (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
.all ⇒ Object
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
#name ⇒ Object
54 55 56 |
# File 'app/values/renalware/gender.rb', line 54 def name DATA[code] end |
#nhs_dictionary_number ⇒ Object
62 63 64 |
# File 'app/values/renalware/gender.rb', line 62 def nhs_dictionary_number NHS_DICTIONARY_NUMBERS[code] end |
#salutation ⇒ Object
58 59 60 |
# File 'app/values/renalware/gender.rb', line 58 def salutation SALUTATIONS[code] end |
#to_s ⇒ Object
68 69 70 |
# File 'app/values/renalware/gender.rb', line 68 def to_s code end |
#to_str ⇒ Object
72 73 74 |
# File 'app/values/renalware/gender.rb', line 72 def to_str code end |