Class: Contracts::Stringy::URLSafe

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

Overview

A url safe string

See Also:

Class Method Summary collapse

Class Method Details

.generate(*_args) ⇒ Object



81
82
83
# File 'lib/contracts/stringy.rb', line 81

def self.generate(*_args)
  URLSAFE_REGEX.generate
end

.valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/contracts/stringy.rb', line 77

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