Class: Yoda::Model::TypeExpressions::InstanceType
- Defined in:
- lib/yoda/model/type_expressions/instance_type.rb
Instance Attribute Summary collapse
- #path ⇒ ScopedPath readonly
Instance Method Summary collapse
- #change_root(paths) ⇒ self
- #eql?(another) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(path) ⇒ InstanceType
constructor
A new instance of InstanceType.
- #resolve(registry) ⇒ Array<Store::Objects::Base>
- #to_rbs_type(env) ⇒ Object
- #to_s ⇒ String
Methods inherited from Base
Constructor Details
#initialize(path) ⇒ InstanceType
Returns a new instance of InstanceType.
11 12 13 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 11 def initialize(path) @path = ScopedPath.build(path) end |
Instance Attribute Details
#path ⇒ ScopedPath (readonly)
8 9 10 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 8 def path @path end |
Instance Method Details
#change_root(paths) ⇒ self
27 28 29 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 27 def change_root(paths) self.class.new(path.change_scope(paths)) end |
#eql?(another) ⇒ Boolean
16 17 18 19 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 16 def eql?(another) another.is_a?(InstanceType) && path == another.path end |
#hash ⇒ Object
21 22 23 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 21 def hash [self.class.name, path].hash end |
#resolve(registry) ⇒ Array<Store::Objects::Base>
33 34 35 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 33 def resolve(registry) [Store::Query::FindConstant.new(registry).find(path)].compact end |
#to_rbs_type(env) ⇒ Object
43 44 45 46 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 43 def to_rbs_type(env) name = env.resolve_rbs_type_name(path) name ? RBS::Types::ClassInstance.new(name: name, args: [], location: nil) : RBS::Types::Bases::Any.new(location: nil) end |
#to_s ⇒ String
38 39 40 |
# File 'lib/yoda/model/type_expressions/instance_type.rb', line 38 def to_s path.path.to_s end |