HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/rubies/default/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/sig/typename.rbs
module RBS
  # TypeName represents name of types in RBS.
  #
  # TypeNames are one of the three kind, class, alias, and interface.
  # *class* type names corresponds to Ruby classes and modules.
  # There are no corresponding Ruby value to *alias* and *interface* type names.
  #
  class TypeName
    # Type of type names.
    #
    type kind = :class | :alias | :interface

    # The namespace the type name is defined in.
    attr_reader namespace: Namespace

    # Name of type name.
    attr_reader name: Symbol

    # Kind of the type.
    attr_reader kind: kind

    # Initializer accepts two keyword args, `namespace` and `name`.
    # Note that `kind` is automatically determined from its `name`.
    #
    # If the name starts with capital alphabet, it is _class_.
    # If the name starts with lower case alphabet, it is _alias_.
    # If the name starts with an underscore, it is _interface_.
    #
    def initialize: (namespace: Namespace, name: Symbol) -> void

    def ==: (untyped other) -> bool

    def hash: () -> Integer

    def to_s: () -> ::String

    def to_json: (*untyped a) -> untyped

    # Returns a namespace with same components of self.
    def to_namespace: () -> Namespace

    # Returns true when self is a _class_ type name.
    def class?: () -> bool

    # Returns true when self is an _alias_ type name.
    def alias?: () -> bool

    def absolute!: () -> TypeName

    def absolute?: () -> bool

    def relative!: () -> TypeName

    # Returns true when self is an _interface_ type name.
    def interface?: () -> bool

    # Returns a new type name with a namespace appended to given namespace.
    #
    #    TypeName("Hello").with_prefix(Namespace("World"))           # => World::Hello
    #    TypeName("Foo::Bar").with_prefix(Namespace("::Hello"))      # => ::Hello::Foo::Bar
    #    TypeName("::A::B").with_prefix(Namespace("C"))              # => ::A::B
    #
    def with_prefix: (Namespace namespace) -> TypeName
  end
end

module Kernel
  # Returns type name with given string representation.
  def TypeName: (String name) -> RBS::TypeName
end