Class: Val

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

Constant Summary collapse

OR =
-> *values do
  -> value do
    values.any? &[:===, value]
  end
end
Bool =
new { OR[true, false] }

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Val

Returns a new instance of Val.



16
17
18
# File 'lib/val.rb', line 16

def initialize &block
  @type = instance_exec &block
end

Instance Method Details

#===(value) ⇒ Object



20
21
22
# File 'lib/val.rb', line 20

def === value
  @type === value
end

#OR(*all) ⇒ Object



10
11
12
# File 'lib/val.rb', line 10

def OR *all
  OR[*all]
end