Class: Uniword::Ooxml::Types::UnsignedDecimalNumber

Inherits:
Lutaml::Model::Type::Integer
  • Object
show all
Defined in:
lib/uniword/ooxml/types/unsigned_decimal_number.rb

Overview

ST_UnsignedDecimalNumber (ECMA-376): non-negative integer

Constrained integer type shared by unsigned OOXML measures (ST_TwipsMeasure, ST_PointMeasure, ST_PixelsMeasure). Negative values raise Lutaml::Model::Type::MinBoundError at cast time (attribute assignment and XML parsing).

Class Method Summary collapse

Class Method Details

.cast(value, options = {}) ⇒ Integer?

Cast a value to a non-negative Integer

Parameters:

  • value (Object)

    the raw value

  • options (Hash) (defaults to: {})

    cast options (unused)

Returns:

  • (Integer, nil)

    the non-negative integer value

Raises:

  • (Lutaml::Model::Type::MinBoundError)

    when negative



21
22
23
24
25
26
# File 'lib/uniword/ooxml/types/unsigned_decimal_number.rb', line 21

def self.cast(value, options = {})
  casted = super
  return casted unless casted.is_a?(::Integer) && casted.negative?

  raise Lutaml::Model::Type::MinBoundError.new(casted, 0)
end