Module: Concurrent::Utility::NativeInteger

Extended by:
NativeInteger
Included in:
NativeInteger
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb

Constant Summary collapse

MIN_VALUE =
- 2))
MAX_VALUE =
(2**(0.size * 8 - 2) - 1)

Instance Method Summary collapse

Instance Method Details

#ensure_integer(value) ⇒ Object



23
24
25
26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 23

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) ⇒ Object



30
31
32
33
34
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 30

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

#ensure_lower_bound(value) ⇒ Object



16
17
18
19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 16

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) ⇒ Object



36
37
38
39
40
41
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 36

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

#ensure_positive_and_no_zero(value) ⇒ Object



43
44
45
46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 43

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) ⇒ Object



9
10
11
12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/utility/native_integer.rb', line 9

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