Class: Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::SimpleElementDef

Inherits:
Schema::SimpleElementDef show all
Defined in:
lib/stupidedi/versions/functional_groups/004010/element_types.rb

Direct Known Subclasses

AN, DT, ID, Nn, R, TM

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Schema::SimpleElementDef

#code_lists, #component_use, #composite?, #simple?, #simple_use

Methods inherited from Schema::AbstractElementDef

#code_lists, #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, description = nil, parent = nil) ⇒ SimpleElementDef

Returns a new instance of SimpleElementDef



30
31
32
33
34
35
36
37
38
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.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 > max_length
    raise ArgumentError,
      "min_length cannot be greater than max_length"
  end
end

Instance Attribute Details

#descriptionString (readonly)

Returns:



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

def description
  @description
end

#idSymbol (readonly)

Returns:



10
11
12
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 10

def id
  @id
end

#max_lengthInteger (readonly)

Returns:



22
23
24
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 22

def max_length
  @max_length
end

#min_lengthInteger (readonly)

Returns:



19
20
21
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 19

def min_length
  @min_length
end

#nameString (readonly)

Returns:



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

def name
  @name
end

#parentSchema::SegmentDef, Schema::CompositeElementDef (readonly)



25
26
27
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 25

def parent
  @parent
end

Instance Method Details

#companionClass<Values::SimpleElementVal>

Returns:



28
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 28

abstract :companion

#copy(changes = {}) ⇒ SimpleElementDef

Returns:



41
42
43
44
45
46
47
48
49
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 41

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

#empty(usage, position) ⇒ Values::SimpleElementVal

Constructs an empty SimpleElementVal



68
69
70
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 68

def empty(usage, position)
  companion.empty(usage, position)
end

#parse(string, usage) ⇒ Values::SimpleElementVal

Constructs a SimpleElementVal from the given String



54
55
56
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 54

def parse(string, usage)
  companion.parse(string, usage)
end

#pretty_print(q)

This method returns an undefined value.



73
74
75
76
77
78
79
80
81
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 73

def pretty_print(q)
  type = self.class.name.try{|n| n.split('::').last }

  if type.blank?
    q.text @id.to_s
  else
    q.text "#{type}[#{@id}]"
  end
end

#value(object, usage, position) ⇒ Values::SimpleElementVal

Constructs a SimpleElementVal from the given value



61
62
63
# File 'lib/stupidedi/versions/functional_groups/004010/element_types.rb', line 61

def value(object, usage, position)
  companion.value(object, usage, position)
end