class RBS::TypeName
属性
kind[R]
name[R]
namespace[R]
公共类方法
new(namespace:, name:) 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 9 def initialize(namespace:, name:) @namespace = namespace @name = name @kind = case when name.match?(/\A[A-Z]/) :class when name.match?(/\A[a-z]/) :alias when name.start_with?("_") :interface else # Defaults to :class :class end end
parse(string) 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 90 def self.parse(string) absolute = string.start_with?("::") *path, name = string.delete_prefix("::").split("::").map(&:to_sym) raise unless name TypeName.new( name: name, namespace: RBS::Namespace.new(path: path, absolute: absolute) ) end
公共实例方法
+(other) 点击切换源码
# File rbs-3.8.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) 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 25 def ==(other) other.is_a?(self.class) && other.namespace == namespace && other.name == name end
也别名为: eql?
absolute!() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 55 def absolute! self.class.new(namespace: namespace.absolute!, name: name) end
absolute?() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 59 def absolute? namespace.absolute? end
alias?() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 51 def alias? kind == :alias end
class?() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 47 def class? kind == :class end
hash() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 31 def hash namespace.hash ^ name.hash end
interface?() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 67 def interface? kind == :interface end
relative!() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 63 def relative! self.class.new(namespace: namespace.relative!, name: name) end
split() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 75 def split namespace.path + [name] end
to_json(state = _ = nil) 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 39 def to_json(state = _ = nil) to_s.to_json(state) end
to_namespace() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 43 def to_namespace namespace.append(self.name) end
to_s() 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 35 def to_s "#{namespace.to_s}#{name}" end
with_prefix(namespace) 点击切换源码
# File rbs-3.8.0/lib/rbs/type_name.rb, line 71 def with_prefix(namespace) self.class.new(namespace: namespace + self.namespace, name: name) end