Class: Contracts::Constraints::Regex

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

Instance Method Summary collapse

Methods inherited from Base

#to_h

Constructor Details

#initialize(regex) ⇒ Regex

Returns a new instance of Regex.



234
# File 'lib/contracts.rb', line 234

def initialize(regex) = @regex = regex

Instance Method Details

#descriptionObject



236
# File 'lib/contracts.rb', line 236

def description = "matching #{@regex.inspect}"

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


235
# File 'lib/contracts.rb', line 235

def matches?(value) = value.is_a?(String) && @regex.match?(value)