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

Inherits:
Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::StringVal show all
Extended by:
Forwardable, Operators::Relational, Operators::Unary, Operators::Wrappers
Includes:
Comparable
Defined in:
lib/stupidedi/versions/functional_groups/003040/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::ThirtyForty::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



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

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:



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

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

#inspectString

Returns:



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

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:



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

def to_s
  ""
end

#to_x12(truncate = true) ⇒ String

Returns:



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

def to_x12(truncate = true)
  ""
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  true
end

#valueObject



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

def value
  ""
end