Class: Stupidedi::Values::AbstractVal

Inherits:
Object
  • Object
show all
Includes:
Color, Inspect
Defined in:
lib/stupidedi/values/abstract_val.rb

Direct Known Subclasses

AbstractElementVal, FunctionalGroupVal, InterchangeVal, InvalidEnvelopeVal, InvalidSegmentVal, LoopVal, SegmentVal, TableVal, TransactionSetVal, TransmissionVal

Instance Method Summary (collapse)

Methods included from Color

ansi, #ansi

Methods included from Inspect

#inspect

Instance Method Details

- (Boolean) blank?

Is the element not present?



41
42
43
# File 'lib/stupidedi/values/abstract_val.rb', line 41

def blank?
  empty?
end

- (AbstractSet<String>) characters(result = Sets.absolute([], Reader::C_BYTES.split(//)))

Returns the set of characters that are used as data in this subtree, not including the separator (delimiter) elements found in the ISA segment.



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/stupidedi/values/abstract_val.rb', line 115

def characters(result = Sets.absolute([], Reader::C_BYTES.split(//)))
  if leaf?
    if present? and not separator?
      result | to_x12.split(//)
    else
      result
    end
  else
    children.inject(result){|r,c| c.characters(r) }
  end
end

- (Boolean) component?

Is this a component SimpleElementVal?



91
92
93
# File 'lib/stupidedi/values/abstract_val.rb', line 91

def component?
  false
end

- (Boolean) composite?

Is this a CompositeElementVal?



86
87
88
# File 'lib/stupidedi/values/abstract_val.rb', line 86

def composite?
  false
end

- (SimpleElementDef, ...) definition



9
# File 'lib/stupidedi/values/abstract_val.rb', line 9

abstract :definition

- (Boolean) element?



81
82
83
# File 'lib/stupidedi/values/abstract_val.rb', line 81

def element?
  false
end

- (Boolean) empty?

See Also:

  • B.1.3.10 Absence of Data


12
13
14
# File 'lib/stupidedi/values/abstract_val.rb', line 12

def empty?
  @children.all?(&:empty?)
end

- (Boolean) functional_group?

Is this an FunctionalGroupVal?



56
57
58
# File 'lib/stupidedi/values/abstract_val.rb', line 56

def functional_group?
  false
end

- (Boolean) interchange?

Is this an InterchangeVal?



51
52
53
# File 'lib/stupidedi/values/abstract_val.rb', line 51

def interchange?
  false
end

- (Boolean) invalid?



31
32
33
# File 'lib/stupidedi/values/abstract_val.rb', line 31

def invalid?
  not valid?
end

- (Boolean) loop?

Is this a LoopVal?



71
72
73
# File 'lib/stupidedi/values/abstract_val.rb', line 71

def loop?
  false
end

- (Boolean) present?

Is the element not blank?



36
37
38
# File 'lib/stupidedi/values/abstract_val.rb', line 36

def present?
  not empty?
end

- (Boolean) repeated?



96
97
98
# File 'lib/stupidedi/values/abstract_val.rb', line 96

def repeated?
  false
end

- (Boolean) segment?



76
77
78
# File 'lib/stupidedi/values/abstract_val.rb', line 76

def segment?
  false
end

- (Boolean) separator?

Is this a simple element that represents a separator (delimiter)? For instance, ISA16 represents the repetition separator in version 00501.



107
108
109
# File 'lib/stupidedi/values/abstract_val.rb', line 107

def separator?
  false
end

- (Boolean) simple?

Is this a non-component SimpleElementVal?



101
102
103
# File 'lib/stupidedi/values/abstract_val.rb', line 101

def simple?
  false
end

- (Integer) size

Number of segments in this subtree



21
22
23
# File 'lib/stupidedi/values/abstract_val.rb', line 21

def size
  @children.sum(&:size)
end

- (Boolean) table?

Is this a TableVal?



66
67
68
# File 'lib/stupidedi/values/abstract_val.rb', line 66

def table?
  false
end

- (Boolean) transaction_set?

Is this an TransactionSetVal?



61
62
63
# File 'lib/stupidedi/values/abstract_val.rb', line 61

def transaction_set?
  false
end

- (Boolean) transmission?

Is this a TransmissionVal?



46
47
48
# File 'lib/stupidedi/values/abstract_val.rb', line 46

def transmission?
  false
end

- (Boolean) valid?

True except for InvalidSegmentVal and Stupidedi::Values::AbstractElementVal values that could not be parsed -- "abc" in a numeric field, for example.



27
28
29
# File 'lib/stupidedi/values/abstract_val.rb', line 27

def valid?
  true
end