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

Inherits:
Stupidedi::Values::SimpleElementVal show all
Extended by:
Forwardable
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

Returns a new instance of SeparatorElementVal.



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

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

Class Method Details

.empty(usage, position) ⇒ Object

Raises:

  • NoMethodError



108
109
110
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 108

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

.parse(character, usage, position) ⇒ SeparatorElementVal

Returns:



118
119
120
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 118

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

.value(character, usage, position) ⇒ SeparatorElementVal

Returns:



113
114
115
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 113

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

Instance Method Details

#copy(changes = {}) ⇒ SeparatorElementVal

Returns:



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

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

#empty?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 76

def empty?
  @value.blank?
end

#inspectObject



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

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

#separator?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 88

def separator?
  true
end

#to_x12String

Returns:



93
94
95
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 93

def to_x12
  @value.to_s
end

#too_long?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 84

def too_long?
  @value.length > 1
end

#too_short?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 80

def too_short?
  @value.length < 1
end

#valid?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/stupidedi/versions/interchanges/00300/element_defs.rb', line 72

def valid?
  true
end