Class: Stupidedi::Schema::InterchangeDef

Inherits:
AbstractDef show all
Includes:
Inspect
Defined in:
lib/stupidedi/schema/interchange_def.rb

Overview

See Also:

  • 3.2.1 Basic Interchange Service Request
  • B.1.1.4.1 Interchange Control Structures

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspect

#inspect

Methods inherited from AbstractDef

#component?, #composite?, #definition?, #element?, #functional_group?, #loop?, #repeated?, #segment?, #simple?, #table?, #transaction_set?, #usage?

Constructor Details

#initialize(id, header_segment_uses, trailer_segment_uses) ⇒ InterchangeDef

Returns a new instance of InterchangeDef.


30
31
32
33
34
35
36
# File 'lib/stupidedi/schema/interchange_def.rb', line 30

def initialize(id, header_segment_uses, trailer_segment_uses)
  @id, @header_segment_uses, @trailer_segment_uses =
    id, header_segment_uses, trailer_segment_uses

  @header_segment_uses  = header_segment_uses.map{|x| x.copy(:parent => self) }
  @trailer_segment_uses = trailer_segment_uses.map{|x| x.copy(:parent => self) }
end

Instance Attribute Details

#header_segment_usesArray<SegmentUse> (readonly)

Returns:


19
20
21
# File 'lib/stupidedi/schema/interchange_def.rb', line 19

def header_segment_uses
  @header_segment_uses
end

#idString (readonly)

Returns:

  • (String)

16
17
18
# File 'lib/stupidedi/schema/interchange_def.rb', line 16

def id
  @id
end

#trailer_segment_usesArray<SegmentUse> (readonly)

Returns:


22
23
24
# File 'lib/stupidedi/schema/interchange_def.rb', line 22

def trailer_segment_uses
  @trailer_segment_uses
end

Instance Method Details

#childrenArray<SegmentUse>

Returns:


52
53
54
# File 'lib/stupidedi/schema/interchange_def.rb', line 52

def children
  @header_segment_uses + @trailer_segment_uses
end

#code_listsAbstractSet<CodeList>

Returns:


62
63
64
# File 'lib/stupidedi/schema/interchange_def.rb', line 62

def code_lists
  children.map(&:code_lists).inject(&:|)
end

#copy(changes = {}) ⇒ InterchangeDef

Returns:


39
40
41
42
43
44
# File 'lib/stupidedi/schema/interchange_def.rb', line 39

def copy(changes = {})
  InterchangeDef.new \
    changes.fetch(:id, @id),
    changes.fetch(:header_segment_uses, @header_segment_uses),
    changes.fetch(:trailer_segment_uses, @trailer_segment_uses)
end

#emptyValues::InterchangeVal


25
# File 'lib/stupidedi/schema/interchange_def.rb', line 25

abstract :empty, :args => %w(separators)

#entry_segment_useSegmentUse

Returns:


47
48
49
# File 'lib/stupidedi/schema/interchange_def.rb', line 47

def entry_segment_use
  @header_segment_uses.head
end

#interchange?Boolean

Returns:

  • (Boolean)

57
58
59
# File 'lib/stupidedi/schema/interchange_def.rb', line 57

def interchange?
  true
end

#pretty_print(q)

This method returns an undefined value.


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/stupidedi/schema/interchange_def.rb', line 67

def pretty_print(q)
  q.text("InterchangeDef[#{id}]")
  q.group(2, "(", ")") do
    q.breakable ""
    @header_segment_uses.each do |e|
      unless q.current_group.first?
        q.text ","
        q.breakable
      end
      q.pp e
    end

    unless q.current_group.first?
      q.text ","
      q.breakable
    end
    q.text "... (FUNCTIONAL GROUPS) ..."

    @trailer_segment_uses.each do |e|
      unless q.current_group.first?
        q.text ","
        q.breakable
      end
      q.pp e
    end
  end
end

#separatorsReader::Separators

Returns:


28
# File 'lib/stupidedi/schema/interchange_def.rb', line 28

abstract :separators, :args => %w(isa_segment_val)