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

Direct Known Subclasses

Versions::FunctionalGroups::FiftyTen::SyntaxNotes::C, Versions::FunctionalGroups::FiftyTen::SyntaxNotes::E, Versions::FunctionalGroups::FiftyTen::SyntaxNotes::L, Versions::FunctionalGroups::FiftyTen::SyntaxNotes::P, Versions::FunctionalGroups::FiftyTen::SyntaxNotes::R, Versions::FunctionalGroups::FortyTen::SyntaxNotes::C, Versions::FunctionalGroups::FortyTen::SyntaxNotes::E, Versions::FunctionalGroups::FortyTen::SyntaxNotes::L, Versions::FunctionalGroups::FortyTen::SyntaxNotes::P, Versions::FunctionalGroups::FortyTen::SyntaxNotes::R, Versions::FunctionalGroups::ThirtyFifty::SyntaxNotes::C, Versions::FunctionalGroups::ThirtyFifty::SyntaxNotes::E, Versions::FunctionalGroups::ThirtyFifty::SyntaxNotes::L, Versions::FunctionalGroups::ThirtyFifty::SyntaxNotes::P, Versions::FunctionalGroups::ThirtyFifty::SyntaxNotes::R, Versions::FunctionalGroups::ThirtyForty::SyntaxNotes::C, Versions::FunctionalGroups::ThirtyForty::SyntaxNotes::E, Versions::FunctionalGroups::ThirtyForty::SyntaxNotes::L, Versions::FunctionalGroups::ThirtyForty::SyntaxNotes::P, Versions::FunctionalGroups::ThirtyForty::SyntaxNotes::R, Versions::FunctionalGroups::ThirtyTen::SyntaxNotes::C, Versions::FunctionalGroups::ThirtyTen::SyntaxNotes::E, Versions::FunctionalGroups::ThirtyTen::SyntaxNotes::L, Versions::FunctionalGroups::ThirtyTen::SyntaxNotes::P, Versions::FunctionalGroups::ThirtyTen::SyntaxNotes::R, Versions::FunctionalGroups::TwoThousandOne::SyntaxNotes::C, Versions::FunctionalGroups::TwoThousandOne::SyntaxNotes::E, Versions::FunctionalGroups::TwoThousandOne::SyntaxNotes::L, Versions::FunctionalGroups::TwoThousandOne::SyntaxNotes::P, Versions::FunctionalGroups::TwoThousandOne::SyntaxNotes::R

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indexes) ⇒ SyntaxNote

Returns a new instance of SyntaxNote.



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

def initialize(indexes)
  @indexes = indexes
end

Instance Attribute Details

#indexesArray<Integer> (readonly)

Returns:



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

def indexes
  @indexes
end

Instance Method Details

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



44
45
46
47
48
49
# File 'lib/stupidedi/schema/syntax_note.rb', line 44

def errors(zipper)
  f = forbidden(zipper).select{|c| c.node.present? }
  r = required(zipper).reject{|c| c.node.present? }

  f.concat(r)
end

#forbiddenArray<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



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

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

#reasonString

Returns:



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

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

#requiredArray<Zipper::AbstractCursor<Values::AbstractElementVal>>

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



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

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

#satisfied?(zipper) ⇒ Boolean

Returns:

  • (Boolean)


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

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