Class: Parlour::Types::Generic
Overview
A user-defined generic class with an arbitrary number of type parameters. This class assumes at least one type_param is provided, otherwise output will have empty type param lists.
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#type_params ⇒ Object
readonly
Returns the value of attribute type_params.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #describe ⇒ Object
- #generate_rbi ⇒ Object
- #generate_rbs ⇒ Object
-
#initialize(type, type_params) ⇒ Generic
constructor
A new instance of Generic.
Methods inherited from Type
Constructor Details
#initialize(type, type_params) ⇒ Generic
Returns a new instance of Generic.
204 205 206 207 |
# File 'lib/parlour/types.rb', line 204 def initialize(type, type_params) @type = to_type(type) @type_params = type_params.map { |p| to_type(p) } end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
217 218 219 |
# File 'lib/parlour/types.rb', line 217 def type @type end |
#type_params ⇒ Object (readonly)
Returns the value of attribute type_params.
220 221 222 |
# File 'lib/parlour/types.rb', line 220 def type_params @type_params end |
Instance Method Details
#==(other) ⇒ Object
210 211 212 213 214 |
# File 'lib/parlour/types.rb', line 210 def ==(other) self.class === other && type == other.type && type_params == other.type_params end |
#describe ⇒ Object
233 234 235 |
# File 'lib/parlour/types.rb', line 233 def describe "#{type.describe}<#{type_params.map(&:describe).join(', ')}>" end |
#generate_rbi ⇒ Object
223 224 225 |
# File 'lib/parlour/types.rb', line 223 def generate_rbi "#{type.generate_rbi}[#{type_params.map(&:generate_rbi).join(', ')}]" end |
#generate_rbs ⇒ Object
228 229 230 |
# File 'lib/parlour/types.rb', line 228 def generate_rbs "#{type.generate_rbs}[#{type_params.map(&:generate_rbs).join(', ')}]" end |