Class: Stupidedi::Schema::TransactionSetDef

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Inspect

#inspect

Methods inherited from AbstractDef

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

Constructor Details

#initialize(functional_group, id, name, table_defs) ⇒ TransactionSetDef

Returns a new instance of TransactionSetDef.



19
20
21
22
23
24
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 19

def initialize(functional_group, id, name, table_defs)
  @functional_group, @id, @name, @table_defs =
    functional_group, id, name, table_defs

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

Instance Attribute Details

#functional_groupString (readonly)

Returns:



14
15
16
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 14

def functional_group
  @functional_group
end

#idString (readonly)

Returns:



8
9
10
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 8

def id
  @id
end

#nameString (readonly)

Returns:



11
12
13
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 11

def name
  @name
end

#table_defsArray<TableDef> (readonly)

Returns:



17
18
19
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 17

def table_defs
  @table_defs
end

Class Method Details

.build(functional_group, id, name, *table_defs) ⇒ TransactionSetDef

Returns:



82
83
84
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 82

def build(functional_group, id, name, *table_defs)
  new(functional_group, id, name, table_defs)
end

Instance Method Details

#code_listsAbstractSet<CodeList>

Returns:



59
60
61
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 59

def code_lists
  @table_defs.map(&:code_lists).inject(&:|)
end

#copy(changes = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 26

def copy(changes = {})
  TransactionSetDef.new \
    changes.fetch(:functional_group, @functional_group),
    changes.fetch(:id, @id),
    changes.fetch(:name, @name),
    changes.fetch(:table_defs, @table_defs)
end

#emptyValues::TransactionSetVal



35
36
37
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 35

def empty
  Values::TransactionSetVal.new(self, [])
end

#entry_segment_useSegmentUse

Returns:



40
41
42
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 40

def entry_segment_use
  @table_defs.head.header_segment_uses.head
end

#first_segment_useSegmentUse

Returns:



45
46
47
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 45

def first_segment_use
  @table_defs.head.header_segment_uses.head
end

#last_segment_useSegmentUse

Returns:



50
51
52
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 50

def last_segment_use
  @table_defs.last.trailer_segment_uses.last
end

#pretty_print(q) ⇒ void

This method returns an undefined value.



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 64

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

#transaction?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/stupidedi/schema/transaction_set_def.rb', line 54

def transaction?
  true
end