Class: Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::FloatVal

Inherits:
Stupidedi::Values::SimpleElementVal show all
Defined in:
lib/stupidedi/versions/functional_groups/004010/element_types/float_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?, #simple?, #string?, #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

+ (FloatVal) empty(usage, position)

Returns:



323
324
325
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/float_val.rb', line 323

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

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

Returns:



328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/float_val.rb', line 328

def value(object, usage, position)
  if object.blank?
    self::Empty.new(usage, position)
  elsif object.respond_to?(:to_d)
    begin
      self::NonEmpty.new(object.to_d, usage, position)
    rescue ArgumentError
      self::Invalid.new(object, usage, position)
    end
  else
    self::Invalid.new(object, usage, position)
  end
end

Instance Method Details

- (Boolean) numeric?

PATTERN = /\A[+-]? (?# optional leading sign ) (?: (?:\d+.?\d) | (?# whole with optional decimal or ..) (?:\d?.?\d+) ) (?# optional whole with decimal ) (?:E[+-]?\d+)? (?# optional exponent ) \Z/ix

Returns:

  • (Boolean)


40
41
42
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/float_val.rb', line 40

def numeric?
  true
end

- (Boolean) too_long?

Returns:

  • (Boolean)


44
45
46
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/float_val.rb', line 44

def too_long?
  false
end

- (Boolean) too_short?

Returns:

  • (Boolean)


48
49
50
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/float_val.rb', line 48

def too_short?
  false
end