Class: RBS::Types::Alias

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:) ⇒ Alias

Returns a new instance of Alias.



335
336
337
338
339
# File 'lib/rbs/types.rb', line 335

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



331
332
333
# File 'lib/rbs/types.rb', line 331

def location
  @location
end

Instance Method Details

#map_type(&block) ⇒ Object



357
358
359
360
361
362
363
364
365
366
367
# File 'lib/rbs/types.rb', line 357

def map_type(&block)
  if block
    Alias.new(
      name: name,
      args: args.map {|type| yield type },
      location: location
    )
  else
    enum_for :map_type
  end
end

#map_type_name(&block) ⇒ Object



349
350
351
352
353
354
355
# File 'lib/rbs/types.rb', line 349

def map_type_name(&block)
  Alias.new(
    name: yield(name, location, self),
    args: args.map {|arg| arg.map_type_name(&block) },
    location: location
  )
end

#sub(s) ⇒ Object



345
346
347
# File 'lib/rbs/types.rb', line 345

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

#to_json(state = _ = nil) ⇒ Object



341
342
343
# File 'lib/rbs/types.rb', line 341

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