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

Returns a new instance of Invalid



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

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

Instance Attribute Details

#valueObject (readonly)

Returns:

  • (Object)


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

def value
  @value
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  false
end

#inspectString

Returns:

  • (String)


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

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

Returns:



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

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

#to_sString

Returns:

  • (String)


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

def to_s
  ""
end

#to_x12(truncate = true) ⇒ String

Returns:

  • (String)


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

def to_x12(truncate = true)
  ""
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  false
end