Class: Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::StringVal::Invalid

Inherits:
Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::StringVal show all
Defined in:
lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb

Overview

Objects passed to StringVal.value that don't respond to #to_s are modeled by this class. Note most everything in Ruby responds to that method, including things that really shouldn't be considered StringVals (like Array or Class), so other validation should be performed on StringVal::NonEmpty values.

Instance Attribute Summary collapse

Attributes inherited from Stupidedi::Values::SimpleElementVal

#position, #usage

Instance Method Summary collapse

Methods inherited from Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::StringVal

empty, #string?, #too_long?, #too_short?, value

Methods inherited from Stupidedi::Values::SimpleElementVal

#allowed?, #component?, #copy, #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?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?

Methods included from Color

ansi, #ansi

Constructor Details

#initialize(value, usage, position) ⇒ Invalid



50
51
52
53
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 50

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

Instance Attribute Details

#valueObject (readonly)



48
49
50
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 48

def value
  @value
end

Instance Method Details

#==(other) ⇒ Boolean



96
97
98
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 96

def ==(other)
  eql?(other) or other.nil?
end

#empty?Boolean



59
60
61
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 59

def empty?
  false
end

#inspectString



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 69

def inspect
  id = definition.bind do |d|
    "[#{'% 5s' % d.id}: #{d.name}]".bind do |s|
      if usage.forbidden?
        ansi.forbidden(s)
      elsif usage.required?
        ansi.required(s)
      else
        ansi.optional(s)
      end
    end
  end

  ansi.element("AN.invalid#{id}") << "(#{ansi.invalid(@value.inspect)})"
end

#mapStringVal



64
65
66
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 64

def map
  StringVal.value(yield(nil), usage, position)
end

#to_sString



86
87
88
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 86

def to_s
  ""
end

#to_x12(truncate = true) ⇒ String



91
92
93
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 91

def to_x12(truncate = true)
  ""
end

#valid?Boolean



55
56
57
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 55

def valid?
  false
end