Class: Stupidedi::TransactionSets::Validation::Ambiguity
- Inherits:
-
Object
- Object
- Stupidedi::TransactionSets::Validation::Ambiguity
- Includes:
- Color, Parser::Tokenization
- Defined in:
- lib/stupidedi/transaction_sets/validation/ambiguity.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
Class Method Summary collapse
- .build(transaction_set_def, functional_group_def) ⇒ Object
- .mkconfig(definition, functional_group_def, isa11, gs01, gs08, st01) ⇒ Object
Instance Method Summary collapse
- #audit ⇒ Object
-
#initialize(machine, reader, isa_elements, gs_elements, st_elements) ⇒ Ambiguity
constructor
A new instance of Ambiguity.
Methods included from Parser::Tokenization
#blank, #composite, #default, #not_used, #repeated
Methods included from Color
Constructor Details
#initialize(machine, reader, isa_elements, gs_elements, st_elements) ⇒ Ambiguity
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 19 def initialize(machine, reader, isa_elements, gs_elements, st_elements) @config = machine.config @reader = reader @queue = [] @queued = Set.new @elements = Hash.new{|h,k| h[k] = [] } @elements[:ISA] = isa_elements @elements[:GS] = gs_elements @elements[:ST] = st_elements enqueue(machine.active.head) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 14 def config @config end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
15 16 17 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 15 def machine @machine end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
17 18 19 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 17 def queue @queue end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
16 17 18 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 16 def reader @reader end |
Class Method Details
.build(transaction_set_def, functional_group_def) ⇒ Object
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 334 def build(transaction_set_def, functional_group_def) # Use dummy identifiers to link transaction_set_def to the parser config = mkconfig(transaction_set_def, functional_group_def, "ISA11", "GS01", "GS08", "ST01") builder = Parser::BuilderDsl.new(Parser.build(config, Zipper::Stack), false) # These lists of elements are re-used when Ambiguity needs to construct # an ISA, GS, or ST segment as it walks the transaction_set_def isa_elements = [ "00", "AUTHORIZATION", "00", "PASSWORD", "ZZ", "SUBMITTER ID", "ZZ", "RECEIVER ID", "191225", "1230", "^", "ISA11", "123456789", "0", "T", ":" ] gs_elements = [ "GS01", "SENDER ID", "RECEIVER ID", "20191225", "1230", "1", "X", "GS08" ] st_elements = [ "ST01", "1234" ] builder.ISA(*isa_elements) builder.GS(*gs_elements) builder.ST(*st_elements) new(builder.machine, builder.reader, isa_elements, gs_elements, st_elements) end |
.mkconfig(definition, functional_group_def, isa11, gs01, gs08, st01) ⇒ Object
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 371 def mkconfig(definition, functional_group_def, isa11, gs01, gs08, st01) Config.new.customize do |c| c.interchange.customize do |x| # We can use whatever interchange version we like, it does not # have any bearing or relationship to the given `definition` x.register(isa11, Interchanges::FiveOhOne::InterchangeDef) end c.functional_group.customize do |x| x.register(gs08, functional_group_def) end c.transaction_set.customize do |x| x.register(gs08, gs01, st01, definition) end end end |
Instance Method Details
#audit ⇒ Object
33 34 35 36 37 |
# File 'lib/stupidedi/transaction_sets/validation/ambiguity.rb', line 33 def audit while cursor = @queue.shift step(Stupidedi::Parser::StateMachine.new(@config, [cursor])) end end |