Class: Stupidedi::Versions::Common::ElementTypes::SimpleElementDef
Instance Attribute Summary collapse
Instance Method Summary
collapse
#code_lists, #component_use, #composite?, #parse, #simple?, #simple_use
#code_lists, #composite?, #descriptor, #element?, #simple?
Methods included from Inspect
#inspect
#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, description = nil, parent = nil) ⇒ SimpleElementDef
Returns a new instance of SimpleElementDef.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 30
def initialize(id, name, min_length, max_length, description = nil, parent = nil)
@id, @name, @min_length, @max_length, @description, @parent =
id, name, min_length, max_length, description, parent
if min_length < 1
raise Exceptions::InvalidSchemaError,
"min_length must be positive"
end
if min_length > max_length
raise Exceptions::InvalidSchemaError,
"min_length cannot be greater than max_length"
end
end
|
Instance Attribute Details
#description ⇒ String
16
17
18
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 16
def description
@description
end
|
#id ⇒ Symbol
10
11
12
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 10
def id
@id
end
|
#max_length ⇒ Integer
22
23
24
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 22
def max_length
@max_length
end
|
#min_length ⇒ Integer
19
20
21
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 19
def min_length
@min_length
end
|
#name ⇒ String
13
14
15
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 13
def name
@name
end
|
25
26
27
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 25
def parent
@parent
end
|
Instance Method Details
28
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 28
abstract :companion
|
46
47
48
49
50
51
52
53
54
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 46
def copy(changes = {})
self.class.new \
changes.fetch(:id, @id),
changes.fetch(:name, @name),
changes.fetch(:min_length, @min_length),
changes.fetch(:max_length, @max_length),
changes.fetch(:description, @description),
changes.fetch(:parent, @parent)
end
|
Constructs an empty SimpleElementVal
66
67
68
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 66
def empty(usage, position)
companion.empty(usage, position)
end
|
Constructs a SimpleElementVal from the given value
59
60
61
|
# File 'lib/stupidedi/versions/common/element_types/simple_element.rb', line 59
def value(object, usage, position)
companion.value(object, usage, position)
end
|