Class: RBS::AST::Declarations::Alias

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:, type:, annotations:, location:, comment:) ⇒ Alias

Returns a new instance of Alias.



274
275
276
277
278
279
280
281
# File 'lib/rbs/ast/declarations.rb', line 274

def initialize(name:, type_params:, type:, annotations:, location:, comment:)
  @name = name
  @type_params = type_params
  @type = type
  @annotations = annotations
  @location = location
  @comment = comment
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



270
271
272
# File 'lib/rbs/ast/declarations.rb', line 270

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



272
273
274
# File 'lib/rbs/ast/declarations.rb', line 272

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



271
272
273
# File 'lib/rbs/ast/declarations.rb', line 271

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



269
270
271
# File 'lib/rbs/ast/declarations.rb', line 269

def type
  @type
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



268
269
270
# File 'lib/rbs/ast/declarations.rb', line 268

def type_params
  @type_params
end

Instance Method Details

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



283
284
285
286
287
288
# File 'lib/rbs/ast/declarations.rb', line 283

def ==(other)
  other.is_a?(Alias) &&
    other.name == name &&
    other.type_params == type_params &&
    other.type == type
end

#hashObject



292
293
294
# File 'lib/rbs/ast/declarations.rb', line 292

def hash
  self.class.hash ^ name.hash ^ type_params.hash ^ type.hash
end

#to_json(state = _ = nil) ⇒ Object



296
297
298
299
300
301
302
303
304
305
306
# File 'lib/rbs/ast/declarations.rb', line 296

def to_json(state = _ = nil)
  {
    declaration: :alias,
    name: name,
    type_params: type_params,
    type: type,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(state)
end