class RBS::TypeName

Attributes

kind[R]
name[R]
namespace[R]

Public Class Methods

new(namespace:, name:) click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 9
def initialize(namespace:, name:)
  @namespace = namespace
  @name = name
  @kind = case name.to_s[0,1]
          when /[A-Z]/
            :class
          when /[a-z]/
            :alias
          when "_"
            :interface
          else
            # Defaults to :class
            :class
          end
end

Public Instance Methods

+(other) click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 79
def +(other)
  if other.absolute?
    other
  else
    TypeName.new(
      namespace: self.to_namespace + other.namespace,
      name: other.name
    )
  end
end
==(other) click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 25
def ==(other)
  other.is_a?(self.class) && other.namespace == namespace && other.name == name
end
Also aliased as: eql?
absolute!() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 55
def absolute!
  self.class.new(namespace: namespace.absolute!, name: name)
end
absolute?() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 59
def absolute?
  namespace.absolute?
end
alias?() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 51
def alias?
  kind == :alias
end
class?() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 47
def class?
  kind == :class
end
eql?(other)
Alias for: ==
hash() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 31
def hash
  namespace.hash ^ name.hash
end
interface?() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 67
def interface?
  kind == :interface
end
relative!() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 63
def relative!
  self.class.new(namespace: namespace.relative!, name: name)
end
split() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 75
def split
  namespace.path + [name]
end
to_json(state = _ = nil) click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 39
def to_json(state = _ = nil)
  to_s.to_json(state)
end
to_namespace() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 43
def to_namespace
  namespace.append(self.name)
end
to_s() click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 35
def to_s
  "#{namespace.to_s}#{name}"
end
with_prefix(namespace) click to toggle source
# File rbs-3.1.0/lib/rbs/type_name.rb, line 71
def with_prefix(namespace)
  self.class.new(namespace: namespace + self.namespace, name: name)
end