Class: Parlour::Types::Union
Overview
A type which is (at least) one of the wrapped types.
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #describe ⇒ Object
- #generate_rbi ⇒ Object
- #generate_rbs ⇒ Object
-
#initialize(types) ⇒ Union
constructor
A new instance of Union.
Methods inherited from Type
Constructor Details
#initialize(types) ⇒ Union
Returns a new instance of Union.
109 110 111 |
# File 'lib/parlour/types.rb', line 109 def initialize(types) @types = types.map(&method(:to_type)) end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
119 120 121 |
# File 'lib/parlour/types.rb', line 119 def types @types end |
Instance Method Details
#==(other) ⇒ Object
114 115 116 |
# File 'lib/parlour/types.rb', line 114 def ==(other) Union === other && types == other.types end |
#describe ⇒ Object
132 133 134 |
# File 'lib/parlour/types.rb', line 132 def describe "Union<#{types.map(&:describe).join(', ')}>" end |
#generate_rbi ⇒ Object
122 123 124 |
# File 'lib/parlour/types.rb', line 122 def generate_rbi "T.any(#{types.map(&:generate_rbi).join(', ')})" end |
#generate_rbs ⇒ Object
127 128 129 |
# File 'lib/parlour/types.rb', line 127 def generate_rbs "(#{types.map(&:generate_rbs).join(' | ')})" end |