123456789_123456789_123456789_123456789_123456789_

Module: Concurrent::Utility::NativeInteger Private

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: lib/concurrent-ruby/concurrent/utility/native_integer.rb

Constant Summary

Instance Method Summary

Instance Method Details

#ensure_integer(value)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 24

def ensure_integer(value)
  unless value.is_a?(Integer)
    raise ArgumentError.new("#{value} is not an Integer")
  end
  value
end

#ensure_integer_and_bounds(value)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 31

def ensure_integer_and_bounds(value)
  ensure_integer value
  ensure_upper_bound value
  ensure_lower_bound value
end

#ensure_lower_bound(value)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 17

def ensure_lower_bound(value)
  if value < MIN_VALUE
    raise RangeError.new("#{value} is less than the maximum value of #{MIN_VALUE}")
  end
  value
end

#ensure_positive(value)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 37

def ensure_positive(value)
  if value < 0
    raise ArgumentError.new("#{value} cannot be negative")
  end
  value
end

#ensure_positive_and_no_zero(value)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 44

def ensure_positive_and_no_zero(value)
  if value < 1
    raise ArgumentError.new("#{value} cannot be negative or zero")
  end
  value
end

#ensure_upper_bound(value)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 10

def ensure_upper_bound(value)
  if value > MAX_VALUE
    raise RangeError.new("#{value} is greater than the maximum value of #{MAX_VALUE}")
  end
  value
end