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, #has_classish_type?, #has_self_type?, #hash, #to_s, #with_nonreturn_void?

Constructor Details

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

Returns a new instance of Interface.



315
316
317
318
319
# File 'lib/rbs/types.rb', line 315

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



311
312
313
# File 'lib/rbs/types.rb', line 311

def location
  @location
end

Instance Method Details

#map_type(&block) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
# File 'lib/rbs/types.rb', line 339

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

#map_type_name(&block) ⇒ Object



331
332
333
334
335
336
337
# File 'lib/rbs/types.rb', line 331

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



325
326
327
328
329
# File 'lib/rbs/types.rb', line 325

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

#to_json(state = _ = nil) ⇒ Object



321
322
323
# File 'lib/rbs/types.rb', line 321

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