Class: Stupidedi::Versions::Common::ElementTypes::StringVal

Inherits:
Stupidedi::Values::SimpleElementVal show all
Defined in:
lib/stupidedi/versions/common/element_types/an.rb

Overview

See Also:

  • B.1.1.3.1.4 String

Direct Known Subclasses

Invalid, Valid

Defined Under Namespace

Classes: Empty, Invalid, NonEmpty, Valid

Instance Attribute Summary

Attributes inherited from Stupidedi::Values::SimpleElementVal

#position, #usage

Constructors collapse

Instance Method Summary collapse

Methods inherited from Stupidedi::Values::SimpleElementVal

#allowed?, #component?, #copy, #date?, #id?, #initialize, #leaf?, #numeric?, #simple?, #time?, #to_s, #to_x12, #valid?

Methods inherited from Stupidedi::Values::AbstractElementVal

#element?, #size

Methods inherited from Stupidedi::Values::AbstractVal

#blank?, #characters, #component?, #composite?, #definition, #descriptor, #element?, #empty?, #functional_group?, #interchange?, #invalid?, #leaf?, #loop?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?

Methods included from Color

ansi, #ansi

Methods included from Inspect

#inspect

Constructor Details

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

Class Method Details

.empty(usage, position) ⇒ StringVal

Returns:



346
347
348
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 346

def empty(usage, position)
  self::Empty.new(usage, position)
end

.value(object, usage, position) ⇒ StringVal

Returns:



351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 351

def value(object, usage, position)
  if object.is_a?(StringVal)
    object#.copy(:usage => usage, :position => position)
  elsif object.blank?
    self::Empty.new(usage, position)
  elsif object.kind_of?(Date) or object.kind_of?(Time)
    self::Invalid.new(object, usage, position)
  else
    self::NonEmpty.new(object.to_s.rstrip, usage, position)
  end
rescue
  self::Invalid.new(object, usage, position)
end

Instance Method Details

#string?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 134

def string?
  true
end

#too_long?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 138

def too_long?
  false
end

#too_short?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 142

def too_short?
  false
end