Class: SafeMe::NilableType
- Inherits:
-
Object
- Object
- SafeMe::NilableType
- Defined in:
- lib/safe-me/nilable_type.rb
Instance Method Summary collapse
-
#initialize(type) ⇒ NilableType
constructor
A new instance of NilableType.
- #to_s ⇒ Object
- #type_of?(obj) ⇒ Boolean
Constructor Details
#initialize(type) ⇒ NilableType
Returns a new instance of NilableType.
3 4 5 |
# File 'lib/safe-me/nilable_type.rb', line 3 def initialize type @type = type end |
Instance Method Details
#to_s ⇒ Object
11 12 13 |
# File 'lib/safe-me/nilable_type.rb', line 11 def to_s "#{@type} or nil" end |
#type_of?(obj) ⇒ Boolean
7 8 9 |
# File 'lib/safe-me/nilable_type.rb', line 7 def type_of? obj obj.nil? or obj.kind_of?(@type) end |