Class: Stupidedi::Versions::Common::ElementTypes::ID

Inherits:
SimpleElementDef show all
Defined in:
lib/stupidedi/versions/common/element_types/id.rb

Instance Attribute Summary collapse

Attributes inherited from SimpleElementDef

#description, #id, #max_length, #min_length, #name, #parent

Attributes inherited from Schema::AbstractElementDef

#description, #id, #name

Instance Method Summary collapse

Methods inherited from SimpleElementDef

#empty, #value

Methods inherited from Schema::SimpleElementDef

#code_lists, #composite?, #empty, #parent, #parse, #simple?, #value

Methods inherited from Schema::AbstractElementDef

#code_lists, #composite?, #descriptor, #element?, #simple?

Methods included from Inspect

#inspect

Methods inherited from Schema::AbstractDef

#component?, #composite?, #definition?, #descriptor, #element?, #functional_group?, #interchange?, #loop?, #repeated?, #required?, #segment?, #simple?, #table?, #transaction_set?, #usage?

Constructor Details

#initialize(id, name, min_length, max_length, code_list = nil, description = nil, parent = nil) ⇒ ID

Returns a new instance of ID.


12
13
14
15
# File 'lib/stupidedi/versions/common/element_types/id.rb', line 12

def initialize(id, name, min_length, max_length, code_list = nil, description = nil, parent = nil)
  super(id, name, min_length, max_length, description, parent)
  @code_list = code_list
end

Instance Attribute Details

#code_listSchema::CodeList (readonly)

Returns:


10
11
12
# File 'lib/stupidedi/versions/common/element_types/id.rb', line 10

def code_list
  @code_list
end

Instance Method Details

#companion


17
18
19
# File 'lib/stupidedi/versions/common/element_types/id.rb', line 17

def companion
  IdentifierVal
end

#component_use(requirement, parent = nil) ⇒ ComponentElementUse

Returns:

  • (ComponentElementUse)

43
44
45
46
47
48
49
# File 'lib/stupidedi/versions/common/element_types/id.rb', line 43

def component_use(requirement, parent = nil)
  if @code_list.try(:internal?)
    Schema::ComponentElementUse.new(self, requirement, Sets.absolute(@code_list.codes), parent)
  else
    Schema::ComponentElementUse.new(self, requirement, Sets.universal, parent)
  end
end

#copy(changes = {}) ⇒ ID

Returns:


22
23
24
25
26
27
28
29
30
31
# File 'lib/stupidedi/versions/common/element_types/id.rb', line 22

def copy(changes = {})
  ID.new \
    changes.fetch(:id, @id),
    changes.fetch(:name, @name),
    changes.fetch(:min_length, @min_length),
    changes.fetch(:max_length, @max_length),
    changes.fetch(:code_list, @code_list),
    changes.fetch(:description, @description),
    changes.fetch(:parent, @parent)
end

#simple_use(requirement, repeat_count, parent = nil) ⇒ SimpleElementUse

Returns:

  • (SimpleElementUse)

34
35
36
37
38
39
40
# File 'lib/stupidedi/versions/common/element_types/id.rb', line 34

def simple_use(requirement, repeat_count, parent = nil)
  if @code_list.try(:internal?)
    Schema::SimpleElementUse.new(self, requirement, repeat_count, Sets.absolute(@code_list.codes), parent)
  else
    Schema::SimpleElementUse.new(self, requirement, repeat_count, Sets.universal, parent)
  end
end