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

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



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

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

Class Method Details

.empty(usage, position) ⇒ Object

Raises:

  • NoMethodError



109
110
111
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 109

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

.parse(character, usage, position) ⇒ SeparatorElementVal

Returns:



119
120
121
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 119

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

.value(character, usage, position) ⇒ SeparatorElementVal

Returns:



114
115
116
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 114

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

Instance Method Details

#copy(changes = {}) ⇒ SeparatorElementVal

Returns:



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

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

#empty?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 77

def empty?
  @value.blank?
end

#inspectObject



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

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

#separator?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 89

def separator?
  true
end

#to_x12String

Returns:



94
95
96
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 94

def to_x12
  @value.to_s
end

#too_long?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 85

def too_long?
  @value.length > 1
end

#too_short?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 81

def too_short?
  @value.length < 1
end

#valid?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/stupidedi/versions/interchanges/00401/element_defs.rb', line 73

def valid?
  true
end