Class: Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::StringVal

Inherits:
Stupidedi::Values::SimpleElementVal show all
Defined in:
lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb

Overview

See Also:

Direct Known Subclasses

Empty, Invalid, NonEmpty

Defined Under Namespace

Classes: Empty, Invalid, NonEmpty

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_x12

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?, #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

+ (StringVal) empty(usage, position)

Returns:



373
374
375
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 373

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

+ (StringVal) value(object, usage, position)

Returns:



378
379
380
381
382
383
384
385
386
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 378

def value(object, usage, position)
  if object.blank?
    self::Empty.new(usage, position)
  elsif object.respond_to?(:to_s)
    self::NonEmpty.new(object.to_s.rstrip, usage, position)
  else
    self::Invalid.new(object, usage, position)
  end
end

Instance Method Details

- (StringVal) map

Returns:



31
32
33
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 31

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

- (Boolean) string?

Returns:

  • (Boolean)


18
19
20
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 18

def string?
  true
end

- (Boolean) too_long?

Returns:

  • (Boolean)


22
23
24
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 22

def too_long?
  false
end

- (Boolean) too_short?

Returns:

  • (Boolean)


26
27
28
# File 'lib/stupidedi/versions/functional_groups/005010/element_types/string_val.rb', line 26

def too_short?
  false
end