Class: RBS::Types::ClassInstance
- Inherits:
-
Object
- Object
- RBS::Types::ClassInstance
show all
- Includes:
- Application
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
Attributes included from Application
#args, #name
Instance Method Summary
collapse
#==, #each_type, #free_variables, #has_classish_type?, #has_self_type?, #hash, #to_s, #with_nonreturn_void?
Constructor Details
#initialize(name:, args:, location:) ⇒ ClassInstance
Returns a new instance of ClassInstance.
361
362
363
364
365
|
# File 'lib/rbs/types.rb', line 361
def initialize(name:, args:, location:)
@name = name
@args = args
@location = location
end
|
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
357
358
359
|
# File 'lib/rbs/types.rb', line 357
def location
@location
end
|
Instance Method Details
#map_type(&block) ⇒ Object
387
388
389
390
391
392
393
394
395
396
397
|
# File 'lib/rbs/types.rb', line 387
def map_type(&block)
if block
ClassInstance.new(
name: name,
args: args.map {|type| yield type },
location: location
)
else
enum_for :map_type
end
end
|
#map_type_name(&block) ⇒ Object
379
380
381
382
383
384
385
|
# File 'lib/rbs/types.rb', line 379
def map_type_name(&block)
ClassInstance.new(
name: yield(name, location, self),
args: args.map {|type| type.map_type_name(&block) },
location: location
)
end
|
#sub(s) ⇒ Object
371
372
373
374
375
376
377
|
# File 'lib/rbs/types.rb', line 371
def sub(s)
return self if s.empty?
self.class.new(name: name,
args: args.map {|ty| ty.sub(s) },
location: location)
end
|
#to_json(state = _ = nil) ⇒ Object
367
368
369
|
# File 'lib/rbs/types.rb', line 367
def to_json(state = _ = nil)
{ class: :class_instance, name: name, args: args, location: location }.to_json(state)
end
|