Class: Contracts::Constraints::OneOf

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

Instance Method Summary collapse

Methods inherited from Base

#to_h

Constructor Details

#initialize(*values) ⇒ OneOf

Returns a new instance of OneOf.



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

def initialize(*values) = @values = values.freeze

Instance Method Details

#descriptionObject



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

def description = "one of #{@values.inspect}"

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(value) = @values.include?(value)