Class: NcsNavigator::Mdes::VariableType::CodeListEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/ncs_navigator/mdes/variable_type.rb

Overview

A single entry in a code list.

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ CodeListEntry

Returns a new instance of CodeListEntry.



189
190
191
# File 'lib/ncs_navigator/mdes/variable_type.rb', line 189

def initialize(value)
  @value = value
end

Instance Attribute Details

#global_valueString

Returns the MDES's globally-unique identifier for this coded value.

Returns:

  • (String)

    the MDES's globally-unique identifier for this coded value.



158
159
160
# File 'lib/ncs_navigator/mdes/variable_type.rb', line 158

def global_value
  @global_value
end

#labelString

Returns the human-readable label for the entry.

Returns:

  • (String)

    the human-readable label for the entry.



153
154
155
# File 'lib/ncs_navigator/mdes/variable_type.rb', line 153

def label
  @label
end

#master_clString

Returns the name of MDES's master code list from which this value is derived.

Returns:

  • (String)

    the name of MDES's master code list from which this value is derived.



163
164
165
# File 'lib/ncs_navigator/mdes/variable_type.rb', line 163

def master_cl
  @master_cl
end

#valueString (readonly) Also known as: to_s

Returns the local code value for the entry.

Returns:

  • (String)

    the local code value for the entry.



149
150
151
# File 'lib/ncs_navigator/mdes/variable_type.rb', line 149

def value
  @value
end

Class Method Details

.from_xsd_enumeration(enum, options = {}) ⇒ CodeListEntry

Creates a new instance from a xs:enumeration simple type restriction subelement.

Parameters:

  • enum (Nokogiri::XML::Element)

    the xs:enumeration element.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :log (#warn)

    the logger to which to direct warnings

Returns:



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/ncs_navigator/mdes/variable_type.rb', line 176

def from_xsd_enumeration(enum, options={})
  log = options[:log] || NcsNavigator::Mdes.default_logger

  log.warn("Missing value for code list entry on line #{enum.line}") unless enum['value']

  new(enum['value'] && enum['value'].strip).tap do |cle|
    cle.label = enum['label']
    cle.global_value = enum['global_value']
    cle.master_cl = enum['master_cl']
  end
end