Class: Types::Interface
- Inherits:
-
Object
- Object
- Types::Interface
- Includes:
- Generic
- Defined in:
- lib/types/interface.rb
Overview
Represents an RBS interface type.
“‘ruby type = Types::Interface.new(“MyInterface”) type.to_rbs # => “_MyInterface” type.to_s # => “Interface(MyInterface)” “`
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #composite? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name) ⇒ Interface
constructor
A new instance of Interface.
- #to_rbs ⇒ Object
- #to_s ⇒ Object
Methods included from Generic
Constructor Details
#initialize(name) ⇒ Interface
Returns a new instance of Interface.
20 21 22 |
# File 'lib/types/interface.rb', line 20 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/types/interface.rb', line 25 def name @name end |
Instance Method Details
#==(other) ⇒ Object
51 52 53 |
# File 'lib/types/interface.rb', line 51 def == other other.is_a?(Interface) && @name == other.name end |
#hash ⇒ Object
56 57 58 |
# File 'lib/types/interface.rb', line 56 def hash @name.hash end |
#to_rbs ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/types/interface.rb', line 38 def to_rbs if @name.include?("::") # For nested interfaces like "MyLibrary::MyInterface", return "MyLibrary::_MyInterface" parts = @name.split("::") parts[-1] = "_#{parts[-1]}" parts.join("::") else # For simple interfaces like "MyInterface", return "_MyInterface" "_#{@name}" end end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/types/interface.rb', line 33 def to_s "Interface(#{@name})" end |