Class: Stupidedi::Versions::Interchanges::FourOhOne::ElementDefs::SeparatorElementVal

Inherits:
Stupidedi::Values::SimpleElementVal show all
Defined in:
lib/stupidedi/versions/interchanges/00401/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

Returns a new instance of SeparatorElementVal.


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

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

Class Method Details

.empty(usage, position)

Raises:

  • NoMethodError


111
112
113
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 111

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

.parse(character, usage, position) ⇒ SeparatorElementVal

Returns:


121
122
123
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 121

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

.value(character, usage, position) ⇒ SeparatorElementVal

Returns:


116
117
118
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 116

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

Instance Method Details

#copy(changes = {}) ⇒ SeparatorElementVal

Returns:


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

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

#empty?Boolean

Returns:

  • (Boolean)

79
80
81
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 79

def empty?
  @value.blank?
end

#inspect


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

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

#separator?Boolean

Returns:

  • (Boolean)

91
92
93
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 91

def separator?
  true
end

#to_x12String

Returns:

  • (String)

96
97
98
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 96

def to_x12
  @value.to_s
end

#too_long?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 87

def too_long?
  @value.length > 1
end

#too_short?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 83

def too_short?
  @value.length < 1
end

#valid?Boolean

Returns:

  • (Boolean)

75
76
77
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 75

def valid?
  true
end