Class: Stupidedi::Parser::FunctionalGroupState
- Inherits:
-
AbstractState
- Object
- AbstractState
- Stupidedi::Parser::FunctionalGroupState
- Defined in:
- lib/stupidedi/parser/states/functional_group_state.rb
Instance Attribute Summary collapse
- #children ⇒ Array<AbstractState> readonly
-
#gs01 ⇒ String
readonly
GS01: Functional Identifier Code.
-
#gs08 ⇒ String
readonly
GS08: Version / Release / Industry Identifier Code.
- #instructions ⇒ InstructionTable readonly
- #segment_dict ⇒ Reader::SegmentDict readonly
- #separators ⇒ Reader::Separators readonly
- #zipper ⇒ Zipper::AbstractCursor readonly
Constructors collapse
Instance Method Summary collapse
- #copy(changes = {}) ⇒ FunctionalGroupState
-
#initialize(separators, segment_dict, instructions, zipper, children, gs01, gs08) ⇒ FunctionalGroupState
constructor
A new instance of FunctionalGroupState.
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, gs01, gs08) ⇒ FunctionalGroupState
Returns a new instance of FunctionalGroupState.
30 31 32 33 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 30 def initialize(separators, segment_dict, instructions, zipper, children, gs01, gs08) @separators, @segment_dict, @instructions, @zipper, @children, @gs01, @gs08 = separators, segment_dict, instructions, zipper, children, gs01, gs08 end |
Instance Attribute Details
#children ⇒ Array<AbstractState> (readonly)
20 21 22 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 20 def children @children end |
#gs01 ⇒ String (readonly)
GS01: Functional Identifier Code
24 25 26 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 24 def gs01 @gs01 end |
#gs08 ⇒ String (readonly)
GS08: Version / Release / Industry Identifier Code
28 29 30 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 28 def gs08 @gs08 end |
#instructions ⇒ InstructionTable (readonly)
14 15 16 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 14 def instructions @instructions end |
#segment_dict ⇒ Reader::SegmentDict (readonly)
11 12 13 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 11 def segment_dict @segment_dict end |
#separators ⇒ Reader::Separators (readonly)
8 9 10 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 8 def separators @separators end |
#zipper ⇒ Zipper::AbstractCursor (readonly)
17 18 19 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 17 def zipper @zipper end |
Class Method Details
.push(zipper, parent, segment_tok, segment_use, config) ⇒ Zipper::AbstractCursor
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 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 53 def push(zipper, parent, segment_tok, segment_use, config) # GS08: Version / Release / Industry Identifier Code gs08 = segment_tok.element_toks.at(7).try(:value) gs08_version = gs08.try(:slice, 0, 6) # GS01: Functional Identifier Code gs01 = segment_tok.element_toks.at(0).try(:value) unless config.functional_group.defined_at?(gs08_version) return FailureState.push( zipper, parent, segment_tok, "unknown functional group version #{gs08_version.inspect}") end envelope_def = config.functional_group.at(gs08_version) envelope_val = envelope_def.empty segment_use = envelope_def.entry_segment_use segment_val = mksegment(segment_tok, segment_use) zipper.append_child new( parent.separators, parent.segment_dict.push(envelope_val.segment_dict), parent.instructions.push(instructions(envelope_def)), parent.zipper.append(envelope_val).append_child(segment_val), [], gs01, gs08) end |
Instance Method Details
#copy(changes = {}) ⇒ FunctionalGroupState
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/stupidedi/parser/states/functional_group_state.rb', line 36 def copy(changes = {}) FunctionalGroupState.new \ changes.fetch(:separators, @separators), changes.fetch(:segment_dict, @segment_dict), changes.fetch(:instructions, @instructions), changes.fetch(:zipper, @zipper), changes.fetch(:children, @children), changes.fetch(:gs01, @gs01), changes.fetch(:gs08, @gs08) end |