Class: RBS::Types::ClassInstance

Inherits:
Object
  • Object
show all
Includes:
Application
Defined in:
lib/rbs/types.rb

Instance Attribute Summary collapse

Attributes included from Application

#args, #name

Instance Method Summary collapse

Methods included from Application

#==, #each_type, #free_variables, #hash, #to_s

Constructor Details

#initialize(name:, args:, location:) ⇒ ClassInstance

Returns a new instance of ClassInstance.



293
294
295
296
297
# File 'lib/rbs/types.rb', line 293

def initialize(name:, args:, location:)
  @name = name
  @args = args
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



289
290
291
# File 'lib/rbs/types.rb', line 289

def location
  @location
end

Instance Method Details

#map_type(&block) ⇒ Object



317
318
319
320
321
322
323
324
325
326
327
# File 'lib/rbs/types.rb', line 317

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



309
310
311
312
313
314
315
# File 'lib/rbs/types.rb', line 309

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



303
304
305
306
307
# File 'lib/rbs/types.rb', line 303

def sub(s)
  self.class.new(name: name,
                 args: args.map {|ty| ty.sub(s) },
                 location: location)
end

#to_json(state = _ = nil) ⇒ Object



299
300
301
# File 'lib/rbs/types.rb', line 299

def to_json(state = _ = nil)
  { class: :class_instance, name: name, args: args, location: location }.to_json(state)
end