Class: Stupidedi::Schema::SyntaxNote

Inherits:
Object
  • Object
show all
Defined in:
lib/stupidedi/schema/syntax_note.rb

Overview

The 5010 X12 "condition code"s include P - Paired or Multiple (if one then all) R - Required (at least one) E - Exclusion (no more than one) C - Conditional (if first then all) L - List Conditional (if first than at least one more)

See Also:

  • B.1.1.3.5 Syntax Notes
  • B.1.1.3.9 Condition Designator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indexes) ⇒ SyntaxNote

Returns a new instance of SyntaxNote.


21
22
23
# File 'lib/stupidedi/schema/syntax_note.rb', line 21

def initialize(indexes)
  @indexes = indexes
end

Instance Attribute Details

#indexesArray<Integer> (readonly)

Returns:

  • (Array<Integer>)

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

def indexes
  @indexes
end

Instance Method Details

#forbidden(zipper) ⇒ Array<Zipper::AbstractCursor<Values::AbstractElementVal>>

Returns the AbstractElementVals from the given segment or composite element that must not be present, given the presence of other elements


35
# File 'lib/stupidedi/schema/syntax_note.rb', line 35

abstract :forbidden, :args => %w(zipper)

#reason(zipper) ⇒ String

Returns:

  • (String)

38
# File 'lib/stupidedi/schema/syntax_note.rb', line 38

abstract :reason, :args => %w(zipper)

#required(zipper) ⇒ Array<Zipper::AbstractCursor<Values::AbstractElementVal>>

Returns the AbstractElementVals from the given segment or composite element that must be present, given the presence of other elements


29
# File 'lib/stupidedi/schema/syntax_note.rb', line 29

abstract :required, :args => %w(zipper)

#satisfied?(zipper) ⇒ Boolean

Returns:

  • (Boolean)

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

def satisfied?(zipper)
  forbidden(zipper).all?{|c| c.node.blank? } and
    required(zipper).all?{|c| c.node.present? }
end