Class: Stupidedi::Values::AbstractVal

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

Instance Method Summary collapse

Methods included from Color

ansi, #ansi

Methods included from Inspect

#inspect

Instance Method Details

#blank?Boolean

Is the element not present?

Returns:

  • (Boolean)


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

def blank?
  empty?
end

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

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

Returns:

  • (AbstractSet<String>)


119
120
121
122
123
124
125
126
127
128
129
# File 'lib/stupidedi/values/abstract_val.rb', line 119

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

#component?Boolean

Is this a component SimpleElementVal?

Returns:

  • (Boolean)


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

def component?
  false
end

#composite?Boolean

Is this a CompositeElementVal?

Returns:

  • (Boolean)


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

def composite?
  false
end

#definitionSimpleElementDef, ...

Returns:

  • (SimpleElementDef, CompositeElementDef, LoopDef, SegmentDef, TableDef)


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

abstract :definition

#element?Boolean

Returns:

  • (Boolean)


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

def element?
  false
end

#empty?Boolean

Returns:

  • (Boolean)

See Also:

  • B.1.3.10 Absence of Data


16
17
18
# File 'lib/stupidedi/values/abstract_val.rb', line 16

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

#functional_group?Boolean

Is this an FunctionalGroupVal?

Returns:

  • (Boolean)


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

def functional_group?
  false
end

#interchange?Boolean

Is this an InterchangeVal?

Returns:

  • (Boolean)


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

def interchange?
  false
end

#invalid?Boolean

Returns:

  • (Boolean)


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

def invalid?
  not valid?
end

#loop?Boolean

Is this a LoopVal?

Returns:

  • (Boolean)


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

def loop?
  false
end

#present?Boolean

Is the element not blank?

Returns:

  • (Boolean)


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

def present?
  not empty?
end

#repeated?Boolean

Returns:

  • (Boolean)


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

def repeated?
  false
end

#segment?Boolean

Returns:

  • (Boolean)


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

def segment?
  false
end

#separator?Boolean

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

Returns:

  • (Boolean)


111
112
113
# File 'lib/stupidedi/values/abstract_val.rb', line 111

def separator?
  false
end

#simple?Boolean

Is this a non-component SimpleElementVal?

Returns:

  • (Boolean)


105
106
107
# File 'lib/stupidedi/values/abstract_val.rb', line 105

def simple?
  false
end

#sizeInteger

Number of segments in this subtree

Returns:

  • (Integer)


25
26
27
# File 'lib/stupidedi/values/abstract_val.rb', line 25

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

#table?Boolean

Is this a TableVal?

Returns:

  • (Boolean)


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

def table?
  false
end

#transaction_set?Boolean

Is this an TransactionSetVal?

Returns:

  • (Boolean)


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

def transaction_set?
  false
end

#transmission?Boolean

Is this a TransmissionVal?

Returns:

  • (Boolean)


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

def transmission?
  false
end

#valid?Boolean

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

Returns:

  • (Boolean)


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

def valid?
  true
end