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.



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

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.



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

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



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

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



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

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



222
223
224
# File 'lib/rbs/ast/declarations.rb', line 222

def name
  @name
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



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

def type_params
  @type_params
end

Instance Method Details

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



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

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



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

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