Class: Contracts::Stringy::Pos

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

Overview

A string that looks like a positive integer

See Also:

Class Method Summary collapse

Class Method Details

.generate(*args) ⇒ Object



42
43
44
# File 'lib/contracts/stringy.rb', line 42

def self.generate(*args)
  Contracts::Builtin::Pos.generate(*args).to_s
end

.valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/contracts/stringy.rb', line 38

def self.valid?(value)
  value.is_a? String and (value =~ POS_REGEX) != nil
end