Class: Aruba::Contracts::Enum

Inherits:
Contracts::CallableClass
  • Object
show all
Defined in:
lib/aruba/contracts/enum.rb

Overview

Enum

Instance Method Summary collapse

Constructor Details

#initialize(*vals) ⇒ Enum

Create contract


16
17
18
# File 'lib/aruba/contracts/enum.rb', line 16

def initialize(*vals)
  @vals = vals
end

Instance Method Details

#valid?(val) ⇒ Boolean

Check if value is part of array

Returns:

  • (Boolean)

21
22
23
# File 'lib/aruba/contracts/enum.rb', line 21

def valid?(val)
  vals.include? val
end