Class: Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::StringVal::Empty

Inherits:
Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::StringVal show all
Extended by:
Forwardable, Operators::Relational, Operators::Unary, Operators::Wrappers
Includes:
Comparable
Defined in:
lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb

Overview

Empty string value. Shouldn’t be directly instantiated – instead, use the empty constructor.

Instance Attribute Summary

Attributes inherited from Stupidedi::Values::SimpleElementVal

#position, #usage

Instance Method Summary collapse

Methods included from Operators::Wrappers

wrappers

Methods included from Operators::Unary

unary_operators

Methods included from Operators::Relational

relational_operators

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

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

Methods inherited from Stupidedi::Values::SimpleElementVal

#allowed?, #component?, #date?, #id?, #initialize, #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?, #empty?, #functional_group?, #interchange?, #invalid?, #loop?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?

Methods included from Color

ansi, #ansi

Constructor Details

This class inherits a constructor from Stupidedi::Values::SimpleElementVal

Instance Method Details

#coerce(other) ⇒ Object



139
140
141
142
143
144
145
146
147
148
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 139

def coerce(other)
  # me, he = other.coerce(self)
  # me <OP> he
  if other.respond_to?(:to_str)
    return copy(:value => other.to_str), self
  else
    raise TypeError,
      "cannot coerce StringVal to #{other.class}"
  end
end

#copy(changes = {}) ⇒ IdentifierVal

Returns:



132
133
134
135
136
137
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 132

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

#inspectString

Returns:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 159

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.empty#{id}")
end

#to_sString

Returns:



176
177
178
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 176

def to_s
  ""
end

#to_x12(truncate = true) ⇒ String

Returns:



181
182
183
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 181

def to_x12(truncate = true)
  ""
end

#valid?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 154

def valid?
  true
end

#valueObject



150
151
152
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/string_val.rb', line 150

def value
  ""
end