Class: Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::Nn

Inherits:
SimpleElementDef show all
Defined in:
lib/stupidedi/versions/functional_groups/003050/element_types/fixnum_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, #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, #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, precision, description = nil, parent = nil) ⇒ Nn

Returns a new instance of Nn.



15
16
17
18
19
20
21
22
23
24
# File 'lib/stupidedi/versions/functional_groups/003050/element_types/fixnum_val.rb', line 15

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 ArgumentError,
      "precision cannot be greater than max_length"
  end

  @precision = precision
end

Instance Attribute Details

#precisionInteger (readonly)

Returns:

  • (Integer)


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

def precision
  @precision
end

Instance Method Details

#companionObject



43
44
45
# File 'lib/stupidedi/versions/functional_groups/003050/element_types/fixnum_val.rb', line 43

def companion
  FixnumVal
end

#copy(changes = {}) ⇒ Nn

Returns:



27
28
29
30
31
32
33
34
35
36
# File 'lib/stupidedi/versions/functional_groups/003050/element_types/fixnum_val.rb', line 27

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

#pretty_print(q) ⇒ void

This method returns an undefined value.



39
40
41
# File 'lib/stupidedi/versions/functional_groups/003050/element_types/fixnum_val.rb', line 39

def pretty_print(q)
  q.text "N#{@precision}[#{@id}]"
end