Class: RBI::Type::Generic
- Inherits:
-
Type
- Object
- Type
- RBI::Type::Generic
- Defined in:
- lib/rbi/type.rb
Overview
A generic type like T::Array[String] or T::Hash[Symbol, Integer].
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
: String.
-
#params ⇒ Object
readonly
: Array.
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (BasicObject other) -> bool.
-
#initialize(name, *params) ⇒ Generic
constructor
: (String name, *Type params) -> void.
-
#normalize ⇒ Object
: -> Type.
-
#simplify ⇒ Object
: -> Type.
-
#to_rbi ⇒ Object
: -> String.
Constructor Details
#initialize(name, *params) ⇒ Generic
: (String name, *Type params) -> void
555 556 557 558 559 |
# File 'lib/rbi/type.rb', line 555 def initialize(name, *params) super() @name = name @params = params #: Array[Type] end |
Instance Attribute Details
#name ⇒ Object (readonly)
: String
549 550 551 |
# File 'lib/rbi/type.rb', line 549 def name @name end |
#params ⇒ Object (readonly)
: Array
552 553 554 |
# File 'lib/rbi/type.rb', line 552 def params @params end |
Instance Method Details
#==(other) ⇒ Object
: (BasicObject other) -> bool
563 564 565 |
# File 'lib/rbi/type.rb', line 563 def ==(other) Generic === other && @name == other.name && @params == other.params end |
#normalize ⇒ Object
: -> Type
575 576 577 |
# File 'lib/rbi/type.rb', line 575 def normalize self end |
#simplify ⇒ Object
: -> Type
581 582 583 |
# File 'lib/rbi/type.rb', line 581 def simplify self end |
#to_rbi ⇒ Object
: -> String
569 570 571 |
# File 'lib/rbi/type.rb', line 569 def to_rbi "#{@name}[#{@params.map(&:to_rbi).join(", ")}]" end |