Class: Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::ID

Inherits:
SimpleElementDef show all
Defined in:
lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.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, #parse, #pretty_print, #value

Methods inherited from Schema::SimpleElementDef

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

Methods inherited from Schema::AbstractElementDef

#element?

Methods included from Inspect

#inspect

Methods inherited from Schema::AbstractDef

#component?, #composite?, #definition?, #element?, #functional_group?, #interchange?, #loop?, #repeated?, #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.


15
16
17
18
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 15

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:


13
14
15
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 13

def code_list
  @code_list
end

Instance Method Details

#code_lists(subset = Sets.universal)


54
55
56
57
58
59
60
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 54

def code_lists(subset = Sets.universal)
  if @code_list.present?
    @code_list.code_lists(subset)
  else
    Sets.empty
  end
end

#companion


20
21
22
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 20

def companion
  IdentifierVal
end

#component_use(requirement, parent = nil) ⇒ ComponentElementUse

Returns:

  • (ComponentElementUse)

46
47
48
49
50
51
52
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 46

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:


25
26
27
28
29
30
31
32
33
34
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 25

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)

37
38
39
40
41
42
43
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/identifier_val.rb', line 37

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