Class: Stupidedi::Versions::Interchanges::ThreeHundred::ElementDefs::SeparatorElementVal

Inherits:
Stupidedi::Values::SimpleElementVal show all
Defined in:
lib/stupidedi/versions/interchanges/00300/element_defs.rb

Instance Attribute Summary

Attributes inherited from Stupidedi::Values::SimpleElementVal

#position, #usage

Constructors collapse

Instance Method Summary collapse

Methods inherited from Stupidedi::Values::SimpleElementVal

#allowed?, #component?, #date?, #id?, #leaf?, #numeric?, #simple?, #string?, #time?

Methods inherited from Stupidedi::Values::AbstractElementVal

#element?, #size

Methods inherited from Stupidedi::Values::AbstractVal

#blank?, #characters, #component?, #composite?, #definition, #element?, #functional_group?, #interchange?, #invalid?, #loop?, #present?, #repeated?, #segment?, #simple?, #size, #table?, #transaction_set?, #transmission?

Methods included from Color

ansi, #ansi

Constructor Details

#initialize(value, usage, position) ⇒ SeparatorElementVal


61
62
63
64
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 61

def initialize(value, usage, position)
  @value = value
  super(usage, position)
end

Class Method Details

.empty(usage, position)

Raises:

  • NoMethodError


110
111
112
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 110

def empty(usage, position)
  SeparatorElementVal.new(nil, usage, position)
end

.parse(character, usage, position) ⇒ SeparatorElementVal


120
121
122
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 120

def parse(character, usage, position)
  SeparatorElementVal.new(character, usage, position)
end

.value(character, usage, position) ⇒ SeparatorElementVal


115
116
117
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 115

def value(character, usage, position)
  SeparatorElementVal.new(character, usage, position)
end

Instance Method Details

#copy(changes = {}) ⇒ SeparatorElementVal


67
68
69
70
71
72
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 67

def copy(changes = {})
  SeparatorElementVal.new \
    changes.fetch(:value, @value),
    changes.fetch(:usage, usage),
    changes.fetch(:position, position)
end

#empty?Boolean


78
79
80
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 78

def empty?
  @value.blank?
end

#inspect


99
100
101
102
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 99

def inspect
  id = definition.try{|d| ansi.bold("[#{d.id}]") }
  ansi.element("SeparatorElementVal.value#{id}") << "(#{@value || "nil"})"
end

#separator?Boolean


90
91
92
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 90

def separator?
  true
end

#to_x12String


95
96
97
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 95

def to_x12
  @value.to_s
end

#too_long?Boolean


86
87
88
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 86

def too_long?
  @value.length > 1
end

#too_short?Boolean


82
83
84
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 82

def too_short?
  @value.length < 1
end

#valid?Boolean


74
75
76
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 74

def valid?
  true
end