Class: Stupidedi::Versions::Common::ElementTypes::Nn

Inherits:
SimpleElementDef show all
Defined in:
lib/stupidedi/versions/common/element_types/nn.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, #component_use, #composite?, #empty, #parent, #parse, #simple?, #simple_use, #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, precision, description = nil, parent = nil) ⇒ Nn

Returns a new instance of Nn.



12
13
14
15
16
17
18
19
20
21
# File 'lib/stupidedi/versions/common/element_types/nn.rb', line 12

def initialize(id, name, min_length, max_length, precision, description = nil, parent = nil)
  super(id, name, min_length, max_length, description, parent)

  if precision > max_length
    raise Exceptions::InvalidSchemaError,
      "precision cannot be greater than max_length"
  end

  @precision = precision
end

Instance Attribute Details

#precisionInteger (readonly)

Returns:

  • (Integer)


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

def precision
  @precision
end

Instance Method Details

#companion



35
36
37
# File 'lib/stupidedi/versions/common/element_types/nn.rb', line 35

def companion
  FixnumVal
end

#copy(changes = {}) ⇒ Nn

Returns:



24
25
26
27
28
29
30
31
32
33
# File 'lib/stupidedi/versions/common/element_types/nn.rb', line 24

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