Class: Contracts::Builtin::Nat

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts/builtin_contracts.rb

Overview

Check that an argument is a natural number (includes zero).

Class Method Summary collapse

Class Method Details

.valid?(val) ⇒ Boolean

Returns:

  • (Boolean)

55
56
57
# File 'lib/contracts/builtin_contracts.rb', line 55

def self.valid? val
  val.is_a?(Integer) && val >= 0
end