Class: NcsNavigator::Mdes::CodeListEntry

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

Overview

A single entry in a code list.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ CodeListEntry

Returns a new instance of CodeListEntry.



63
64
65
# File 'lib/ncs_navigator/mdes/code_list.rb', line 63

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.



32
33
34
# File 'lib/ncs_navigator/mdes/code_list.rb', line 32

def global_value
  @global_value
end

#labelString

Returns the human-readable label for the entry.

Returns:

  • (String)

    the human-readable label for the entry.



27
28
29
# File 'lib/ncs_navigator/mdes/code_list.rb', line 27

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.



37
38
39
# File 'lib/ncs_navigator/mdes/code_list.rb', line 37

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.



23
24
25
# File 'lib/ncs_navigator/mdes/code_list.rb', line 23

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:



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ncs_navigator/mdes/code_list.rb', line 50

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['ncsdoc:label']
    cle.global_value = enum['ncsdoc:global_value']
    cle.master_cl = enum['ncsdoc:master_cl']
  end
end

Instance Method Details

#diff(other, options = {}) ⇒ Differences::Entry?

Computes the differences between this code list entry and the other.

Returns:



90
91
92
# File 'lib/ncs_navigator/mdes/code_list.rb', line 90

def diff(other, options={})
  Differences::Entry.compute(self, other, diff_criteria(options), options)
end