Class: RBS::TypeName
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/rbs/type_name.rb |
Class Method Summary
-
.[](namespace, name)
Returns a canonical
TypeNameinstance for the given #namespace / #name pair. - .new(namespace:, name:) ⇒ TypeName constructor
- .parse(string)
Instance Attribute Summary
- #absolute? ⇒ Boolean readonly
- #alias? ⇒ Boolean readonly
- #class? ⇒ Boolean readonly
- #interface? ⇒ Boolean readonly
- #kind readonly
- #name readonly
- #namespace readonly
Instance Method Summary
- #+(other)
- #==(other) (also: #eql?)
- #absolute!
-
#eql?(other)
Alias for #==.
- #hash
- #relative!
- #split
- #to_json(state = nil)
- #to_namespace
- #to_s
- #with_prefix(namespace)
Constructor Details
.new(namespace:, name:) ⇒ TypeName
Class Method Details
.[](namespace, name)
Returns a canonical TypeName instance for the given #namespace /
#name pair. The namespace is canonicalized through Namespace.[]
so identity-based lookup works regardless of the caller passing a
fresh Namespace.new or an already-interned instance.
# File 'lib/rbs/type_name.rb', line 36
def self.[](namespace, name) ns = Namespace[namespace.path, namespace.absolute?] inner = @intern_cache[ns] if inner && (cached = inner[name]) return cached end @intern_mutex.synchronize do inner = (@intern_cache[ns] ||= {}) inner[name] ||= new(namespace: ns, name: name) end end
.parse(string)
[ GitHub ]Instance Attribute Details
#absolute? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/rbs/type_name.rb', line 85
def absolute? namespace.absolute? end
#alias? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/rbs/type_name.rb', line 77
def alias? kind == :alias end
#class? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/rbs/type_name.rb', line 73
def class? kind == :class end
#interface? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/rbs/type_name.rb', line 93
def interface? kind == :interface end
#kind (readonly)
[ GitHub ]# File 'lib/rbs/type_name.rb', line 7
attr_reader :kind
#name (readonly)
[ GitHub ]# File 'lib/rbs/type_name.rb', line 6
attr_reader :name
#namespace (readonly)
[ GitHub ]# File 'lib/rbs/type_name.rb', line 5
attr_reader :namespace
Instance Method Details
#+(other)
[ GitHub ]# File 'lib/rbs/type_name.rb', line 105
def +(other) if other.absolute? other else TypeName[self.to_namespace + other.namespace, other.name] end end
#==(other) Also known as: #eql?
[ GitHub ]#absolute!
[ GitHub ]#eql?(other)
Alias for #==.
# File 'lib/rbs/type_name.rb', line 55
alias eql? ==
#hash
[ GitHub ]#relative!
[ GitHub ]#split
[ GitHub ]#to_json(state = nil)
[ GitHub ]# File 'lib/rbs/type_name.rb', line 65
def to_json(state = nil) to_s.to_json(state) end