Class: RBS::AST::Declarations::Interface

Inherits:
Base
  • Object
show all
Includes:
_ToJson, MixinHelper, _HashEqual
Defined in:
lib/rbs/ast/declarations.rb,
sig/declarations.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MixinHelper

#each_mixin

Constructor Details

#initialize(name:, type_params:, members:, annotations:, location:, comment:) ⇒ Interface

Returns a new instance of Interface.

Parameters:



258
259
260
261
262
263
264
265
# File 'lib/rbs/ast/declarations.rb', line 258

def initialize(name:, type_params:, members:, annotations:, location:, comment:)
  @name = name
  @type_params = type_params
  @members = members
  @annotations = annotations
  @location = location
  @comment = comment
end

Instance Attribute Details

#annotationsArray[Annotation] (readonly)

Returns the value of attribute annotations.

Returns:



252
253
254
# File 'lib/rbs/ast/declarations.rb', line 252

def annotations
  @annotations
end

#commentComment? (readonly)

Returns the value of attribute comment.

Returns:



254
255
256
# File 'lib/rbs/ast/declarations.rb', line 254

def comment
  @comment
end

#locationloc? (readonly)

Returns the value of attribute location.

Returns:

  • (loc, nil)


253
254
255
# File 'lib/rbs/ast/declarations.rb', line 253

def location
  @location
end

#membersArray[member] (readonly)

Returns the value of attribute members.

Returns:

  • (Array[member])


251
252
253
# File 'lib/rbs/ast/declarations.rb', line 251

def members
  @members
end

#nameTypeName (readonly)

Returns the value of attribute name.

Returns:



249
250
251
# File 'lib/rbs/ast/declarations.rb', line 249

def name
  @name
end

#type_paramsArray[TypeParam] (readonly)

Returns the value of attribute type_params.

Returns:



250
251
252
# File 'lib/rbs/ast/declarations.rb', line 250

def type_params
  @type_params
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



278
279
280
281
282
283
# File 'lib/rbs/ast/declarations.rb', line 278

def ==(other)
  other.is_a?(Interface) &&
    other.name == name &&
    other.type_params == type_params &&
    other.members == members
end

#hashObject



287
288
289
# File 'lib/rbs/ast/declarations.rb', line 287

def hash
  self.class.hash ^ type_params.hash ^ members.hash
end

#to_json(state = nil) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
# File 'lib/rbs/ast/declarations.rb', line 291

def to_json(state = nil)
  {
    declaration: :interface,
    name: name,
    type_params: type_params,
    members: members,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(state)
end

#update(name: self.name, type_params: self.type_params, members: self.members, annotations: self.annotations, location: self.location, comment: self.comment) ⇒ Declarations::Interface

Parameters:

  • name: (TypeName) (defaults to: self.name)
  • type_params: (Array[TypeParam]) (defaults to: self.type_params)
  • members: (Array[member]) (defaults to: self.members)
  • annotations: (Array[Annotation]) (defaults to: self.annotations)
  • location: (loc, nil) (defaults to: self.location)
  • comment: (Comment, nil) (defaults to: self.comment)

Returns:



267
268
269
270
271
272
273
274
275
276
# File 'lib/rbs/ast/declarations.rb', line 267

def update(name: self.name, type_params: self.type_params, members: self.members, annotations: self.annotations, location: self.location, comment: self.comment)
  self.class.new(
    name: name,
    type_params: type_params,
    members: members,
    annotations: annotations,
    location: location,
    comment: comment
  )
end