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

Inherits:
Object
  • 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.



248
249
250
251
252
253
254
255
# File 'lib/rbs/ast/declarations.rb', line 248

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.



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

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



246
247
248
# File 'lib/rbs/ast/declarations.rb', line 246

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



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

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



241
242
243
# File 'lib/rbs/ast/declarations.rb', line 241

def name
  @name
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



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

def type_params
  @type_params
end

Instance Method Details

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



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

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

#hashObject



266
267
268
# File 'lib/rbs/ast/declarations.rb', line 266

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

#to_json(*a) ⇒ Object



270
271
272
273
274
275
276
277
278
279
280
# File 'lib/rbs/ast/declarations.rb', line 270

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