Class: RBS::Types::Interface

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

Returns a new instance of Interface.



241
242
243
244
245
# File 'lib/rbs/types.rb', line 241

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



237
238
239
# File 'lib/rbs/types.rb', line 237

def location
  @location
end

Instance Method Details

#map_type_name(&block) ⇒ Object



257
258
259
260
261
262
263
# File 'lib/rbs/types.rb', line 257

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

#sub(s) ⇒ Object



251
252
253
254
255
# File 'lib/rbs/types.rb', line 251

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

#to_json(state = _ = nil) ⇒ Object



247
248
249
# File 'lib/rbs/types.rb', line 247

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