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

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

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.



313
314
315
316
317
318
319
320
# File 'lib/rbs/ast/declarations.rb', line 313

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

#annotationsObject (readonly)

Returns the value of attribute annotations.



307
308
309
# File 'lib/rbs/ast/declarations.rb', line 307

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



309
310
311
# File 'lib/rbs/ast/declarations.rb', line 309

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



308
309
310
# File 'lib/rbs/ast/declarations.rb', line 308

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



306
307
308
# File 'lib/rbs/ast/declarations.rb', line 306

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



304
305
306
# File 'lib/rbs/ast/declarations.rb', line 304

def name
  @name
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



305
306
307
# File 'lib/rbs/ast/declarations.rb', line 305

def type_params
  @type_params
end

Instance Method Details

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



322
323
324
325
326
327
# File 'lib/rbs/ast/declarations.rb', line 322

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

#hashObject



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

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

#to_json(*a) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
# File 'lib/rbs/ast/declarations.rb', line 335

def to_json(*a)
  {
    declaration: :interface,
    name: name,
    type_params: type_params,
    members: members,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(*a)
end