class T::Types::TEnum
Validates that an object is equal to another T::Enum
singleton value.
Attributes
val[R]
Public Class Methods
new(val)
click to toggle source
# File lib/types/types/t_enum.rb, line 9 def initialize(val) @val = val end
Public Instance Methods
name()
click to toggle source
@override Base
# File lib/types/types/t_enum.rb, line 14 def name # Strips the #<...> off, just leaving the ... # Reasoning: the user will have written something like # T.any(MyEnum::A, MyEnum::B) # in the type, so we should print what they wrote in errors, not: # T.any(#<MyEnum::A>, #<MyEnum::B>) @val.inspect[2..-2] end
valid?(obj)
click to toggle source
@override Base
# File lib/types/types/t_enum.rb, line 24 def valid?(obj) @val == obj end
Private Instance Methods
subtype_of_single?(other)
click to toggle source
@override Base
# File lib/types/types/t_enum.rb, line 29 def subtype_of_single?(other) case other when TEnum @val == other.val else false end end