Class: Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::FixnumVal

Inherits:
Stupidedi::Values::SimpleElementVal show all
Defined in:
lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_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

+ (FixnumVal) empty(usage, position)

Returns:



290
291
292
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 290

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

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

Returns:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 295

def value(object, usage, position)
  if object.blank?
    self::Empty.new(usage, position)
  elsif object.respond_to?(:to_d)
    # The number of fractional digits is implied by usage.precision
    factor = 10 ** usage.definition.precision

    self::NonEmpty.new(object.to_d / factor, usage, position)
  else
    self::Invalid.new(object, usage, position)
  end
rescue ArgumentError
  self::Invalid.new(object, usage, position)
end

Instance Method Details

- (Boolean) numeric?

Returns:

  • (Boolean)


51
52
53
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 51

def numeric?
  true
end

- (Boolean) too_long?

Returns:

  • (Boolean)


55
56
57
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 55

def too_long?
  false
end

- (Boolean) too_short?

Returns:

  • (Boolean)


59
60
61
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 59

def too_short?
  false
end