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.



233
234
235
236
237
238
239
240
# File 'lib/rbs/ast/declarations.rb', line 233

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.



227
228
229
# File 'lib/rbs/ast/declarations.rb', line 227

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



229
230
231
# File 'lib/rbs/ast/declarations.rb', line 229

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



228
229
230
# File 'lib/rbs/ast/declarations.rb', line 228

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



226
227
228
# File 'lib/rbs/ast/declarations.rb', line 226

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



224
225
226
# File 'lib/rbs/ast/declarations.rb', line 224

def name
  @name
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



225
226
227
# File 'lib/rbs/ast/declarations.rb', line 225

def type_params
  @type_params
end

Instance Method Details

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



242
243
244
245
246
247
# File 'lib/rbs/ast/declarations.rb', line 242

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



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

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