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:

  • B.1.1.3.1.1 Numeric

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

.empty(usage, position) ⇒ FixnumVal



287
288
289
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 287

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

.value(object, usage, position) ⇒ FixnumVal



292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 292

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

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

Instance Method Details

#numeric?Boolean



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

def numeric?
  true
end

#too_long?Boolean



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

def too_long?
  false
end

#too_short?Boolean



62
63
64
# File 'lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb', line 62

def too_short?
  false
end