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

- (Invalid) initialize(value, usage, position)

Returns a new instance of Invalid



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

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

Instance Attribute Details

- (Object) value (readonly)

Returns:



45
46
47
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 45

def value
  @value
end

Instance Method Details

- (Boolean) ==(other)

Returns:

  • (Boolean)


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

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

- (Boolean) empty?

Returns:

  • (Boolean)


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

def empty?
  false
end

- (String) inspect

Returns:



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

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

- (StringVal) map

Returns:



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

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

- (String) to_s

Returns:



83
84
85
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 83

def to_s
  ""
end

- (String) to_x12(truncate = true)

Returns:



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

def to_x12(truncate = true)
  ""
end

- (Boolean) valid?

Returns:

  • (Boolean)


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

def valid?
  false
end