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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Interface.



355
356
357
358
359
360
361
362
# File 'lib/rbs/ast/declarations.rb', line 355

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.



351
352
353
# File 'lib/rbs/ast/declarations.rb', line 351

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



353
354
355
# File 'lib/rbs/ast/declarations.rb', line 353

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



352
353
354
# File 'lib/rbs/ast/declarations.rb', line 352

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



350
351
352
# File 'lib/rbs/ast/declarations.rb', line 350

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



348
349
350
# File 'lib/rbs/ast/declarations.rb', line 348

def name
  @name
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



349
350
351
# File 'lib/rbs/ast/declarations.rb', line 349

def type_params
  @type_params
end

Instance Method Details

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



364
365
366
367
368
369
# File 'lib/rbs/ast/declarations.rb', line 364

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

#hashObject



373
374
375
# File 'lib/rbs/ast/declarations.rb', line 373

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

#to_json(*a) ⇒ Object



377
378
379
380
381
382
383
384
385
386
387
# File 'lib/rbs/ast/declarations.rb', line 377

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