Class: T::Types::TEnum
Overview
Validates that an object is equal to another T::Enum singleton value.
Instance Attribute Summary collapse
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Instance Method Summary collapse
-
#initialize(val) ⇒ TEnum
constructor
A new instance of TEnum.
-
#name ⇒ Object
overrides Base.
-
#valid?(obj) ⇒ Boolean
overrides Base.
Methods inherited from Base
#==, #describe_obj, #error_message_for_obj, #error_message_for_obj_recursive, #hash, method_added, #recursively_valid?, #subtype_of?, #to_s, #validate!
Constructor Details
#initialize(val) ⇒ TEnum
Returns a new instance of TEnum.
9 10 11 |
# File 'lib/types/types/t_enum.rb', line 9 def initialize(val) @val = val end |
Instance Attribute Details
#val ⇒ Object (readonly)
Returns the value of attribute val.
7 8 9 |
# File 'lib/types/types/t_enum.rb', line 7 def val @val end |
Instance Method Details
#name ⇒ Object
overrides Base
14 15 16 17 18 19 20 21 |
# 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) ⇒ Boolean
overrides Base
24 25 26 |
# File 'lib/types/types/t_enum.rb', line 24 def valid?(obj) @val == obj end |