Class: Stupidedi::Interchanges::ElementTypes::SeparatorVal

Inherits:
Values::SimpleElementVal show all
Defined in:
lib/stupidedi/interchanges/element_types/separator_val.rb

Instance Attribute Summary

Attributes inherited from Values::SimpleElementVal

#position, #usage

Constructors collapse

Instance Method Summary collapse

Methods inherited from Values::SimpleElementVal

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

Methods inherited from Values::AbstractElementVal

#element?, #size

Methods inherited from Values::AbstractVal

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

Methods included from Color

ansi, #ansi

Constructor Details

#initialize(value, usage, position) ⇒ SeparatorVal

Returns a new instance of SeparatorVal.



16
17
18
19
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 16

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

Class Method Details

.empty(usage, position)

Raises:

  • NoMethodError



65
66
67
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 65

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

.value(character, usage, position) ⇒ SeparatorVal

Returns:



70
71
72
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 70

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

Instance Method Details

#copy(changes = {}) ⇒ SeparatorVal

Returns:



22
23
24
25
26
27
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 22

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

#empty?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 33

def empty?
  @value.blank?
end

#inspect



54
55
56
57
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 54

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

#separator?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 45

def separator?
  true
end

#to_x12(truncate = true) ⇒ String

Returns:

  • (String)


50
51
52
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 50

def to_x12(truncate = true)
  @value.to_s
end

#too_long?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 41

def too_long?
  @value.length > 1
end

#too_short?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 37

def too_short?
  @value.length < 1
end

#valid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/stupidedi/interchanges/element_types/separator_val.rb', line 29

def valid?
  true
end