Class: Parlour::Types::Nilable
Overview
A type which can be either the wrapped type, or nil.
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #describe ⇒ Object
- #generate_rbi ⇒ Object
- #generate_rbs ⇒ Object
-
#initialize(type) ⇒ Nilable
constructor
A new instance of Nilable.
Methods inherited from Type
Constructor Details
#initialize(type) ⇒ Nilable
Returns a new instance of Nilable.
78 79 80 |
# File 'lib/parlour/types.rb', line 78 def initialize(type) @type = to_type(type) end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
88 89 90 |
# File 'lib/parlour/types.rb', line 88 def type @type end |
Instance Method Details
#==(other) ⇒ Object
83 84 85 |
# File 'lib/parlour/types.rb', line 83 def ==(other) Nilable === other && type == other.type end |
#describe ⇒ Object
101 102 103 |
# File 'lib/parlour/types.rb', line 101 def describe "Nilable<#{type.describe}>" end |
#generate_rbi ⇒ Object
91 92 93 |
# File 'lib/parlour/types.rb', line 91 def generate_rbi "T.nilable(#{type.generate_rbi})" end |
#generate_rbs ⇒ Object
96 97 98 |
# File 'lib/parlour/types.rb', line 96 def generate_rbs "#{type.generate_rbs}?" end |