Class: Stupidedi::Builder::TransactionSetState
- Inherits:
-
AbstractState
- Object
- AbstractState
- Stupidedi::Builder::TransactionSetState
- Defined in:
- lib/stupidedi/builder/states/transaction_set_state.rb
Instance Attribute Summary collapse
- #children ⇒ Array<AbstractState> readonly
- #instructions ⇒ InstructionTable readonly
- #segment_dict ⇒ Reader::SegmentDict readonly
- #separators ⇒ Reader::Separators readonly
- #zipper ⇒ Zipper::AbstractCursor readonly
Constructors collapse
Instance Method Summary collapse
- #copy(changes = {}) ⇒ TransactionSetState
-
#initialize(separators, segment_dict, instructions, zipper, children) ⇒ TransactionSetState
constructor
A new instance of TransactionSetState.
Methods inherited from AbstractState
#leaf?, lsequence, mkcomposite, mkelement, mkrepeated, mksegment, mksimple, #pretty_print, sequence, tsequence
Methods included from Inspect
Constructor Details
#initialize(separators, segment_dict, instructions, zipper, children) ⇒ TransactionSetState
Returns a new instance of TransactionSetState.
21 22 23 24 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 21 def initialize(separators, segment_dict, instructions, zipper, children) @separators, @segment_dict, @instructions, @zipper, @children = separators, segment_dict, instructions, zipper, children end |
Instance Attribute Details
#children ⇒ Array<AbstractState> (readonly)
19 20 21 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 19 def children @children end |
#instructions ⇒ InstructionTable (readonly)
13 14 15 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 13 def instructions @instructions end |
#segment_dict ⇒ Reader::SegmentDict (readonly)
10 11 12 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 10 def segment_dict @segment_dict end |
#separators ⇒ Reader::Separators (readonly)
7 8 9 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 7 def separators @separators end |
#zipper ⇒ Zipper::AbstractCursor (readonly)
16 17 18 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 16 def zipper @zipper end |
Class Method Details
.push(zipper, parent, segment_tok, segment_use, config) ⇒ TransactionSetState
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 42 def push(zipper, parent, segment_tok, segment_use, config) # GS01: Functional Identifier Code fgcode = parent.fgcode # ST01: Transaction Set Identifier Code txcode = segment_tok.element_toks.at(0).try(:value) # ST03: Implementation Convention Reference version = segment_tok.element_toks.at(2).try(:value) # Fall back to GS08 if ST03 isn't available if version.blank? or version.is_a?(Symbol) # GS08: Version / Release / Industry Identifier Code version = parent.version end # Fall back to GS08 if version isn't recognized unless config.transaction_set.defined_at?(version, fgcode, txcode) if config.transaction_set.defined_at?(parent.version, fgcode, txcode) # GS08: Version / Release / Industry Identifier Code version = parent.version end end unless config.transaction_set.defined_at?(version, fgcode, txcode) context = "#{fgcode.inspect} #{txcode.inspect} #{version.inspect}" return FailureState.push( zipper, parent, segment_tok, "unknown transaction set #{context}") end envelope_def = config.transaction_set.at(version, fgcode, txcode) envelope_val = envelope_def.empty segment_use = envelope_def.entry_segment_use zipper = zipper.append_child \ TransactionSetState.new( parent.separators, parent.segment_dict, parent.instructions.push(instructions(envelope_def)), parent.zipper.append(envelope_val).dangle.last, []) TableState.push(zipper, zipper.node, segment_tok, segment_use, config) end |
Instance Method Details
#copy(changes = {}) ⇒ TransactionSetState
27 28 29 30 31 32 33 34 |
# File 'lib/stupidedi/builder/states/transaction_set_state.rb', line 27 def copy(changes = {}) TransactionSetState.new \ changes.fetch(:separators, @separators), changes.fetch(:segment_dict, @segment_dict), changes.fetch(:instructions, @instructions), changes.fetch(:zipper, @zipper), changes.fetch(:children, @children) end |