class T::AnyType
Attributes
types[R]
Public Class Methods
new(*types)
click to toggle source
# File lib/emery/type.rb, line 37 def initialize(*types) @types = types end
Public Instance Methods
==(other)
click to toggle source
# File lib/emery/type.rb, line 49 def ==(other) T.instance_of?(AnyType, other) and (self.types - other.types).empty? end
check(value)
click to toggle source
# File lib/emery/type.rb, line 43 def check(value) type = types.find {|t| T.instance_of?(t, value) } if type == nil raise TypeError.new("Value '#{value.inspect.to_s}' type is #{value.class} - any of #{@types.map { |t| t.to_s}.join(', ')} required") end end
to_s()
click to toggle source
# File lib/emery/type.rb, line 40 def to_s "Any[#{types.map { |t| t.to_s}.join(', ')}]" end