Class: RBI::Type::TypeAlias
Overview
A type alias that references another type by name like ‘MyTypeAlias`.
Instance Attribute Summary collapse
-
#aliased_type ⇒ Object
readonly
: Type.
-
#name ⇒ Object
readonly
: String.
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (BasicObject other) -> bool.
-
#initialize(name, aliased_type) ⇒ TypeAlias
constructor
: (String name, Type aliased_type) -> void.
-
#normalize ⇒ Object
: -> Type.
-
#simplify ⇒ Object
: -> Type.
-
#to_rbi ⇒ Object
: -> String.
Methods inherited from RBI::Type
all, any, anything, attached_class, boolean, class_of, #eql?, generic, #hash, #nilable, nilable, #nilable?, #non_nilable, noreturn, parse_node, parse_string, proc, #rbs_string, self_type, shape, simple, t_class, t_module, #to_s, tuple, type_alias, type_parameter, untyped, void
Constructor Details
#initialize(name, aliased_type) ⇒ TypeAlias
: (String name, Type aliased_type) -> void
631 632 633 634 635 |
# File 'lib/rbi/type.rb', line 631 def initialize(name, aliased_type) super() @name = name @aliased_type = aliased_type end |
Instance Attribute Details
#aliased_type ⇒ Object (readonly)
: Type
628 629 630 |
# File 'lib/rbi/type.rb', line 628 def aliased_type @aliased_type end |
#name ⇒ Object (readonly)
: String
625 626 627 |
# File 'lib/rbi/type.rb', line 625 def name @name end |
Instance Method Details
#==(other) ⇒ Object
: (BasicObject other) -> bool
639 640 641 |
# File 'lib/rbi/type.rb', line 639 def ==(other) TypeAlias === other && @name == other.name && @aliased_type == other.aliased_type end |
#normalize ⇒ Object
: -> Type
651 652 653 |
# File 'lib/rbi/type.rb', line 651 def normalize TypeAlias.new(name, aliased_type.normalize) end |
#simplify ⇒ Object
: -> Type
657 658 659 |
# File 'lib/rbi/type.rb', line 657 def simplify TypeAlias.new(name, aliased_type.simplify) end |
#to_rbi ⇒ Object
: -> String
645 646 647 |
# File 'lib/rbi/type.rb', line 645 def to_rbi "#{name} = ::T.type_alias { #{aliased_type.to_rbi} }" end |