Class: RBS::AST::Declarations::TypeAlias

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:) ⇒ TypeAlias

Returns a new instance of TypeAlias.



312
313
314
315
316
317
318
319
# File 'lib/rbs/ast/declarations.rb', line 312

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.



308
309
310
# File 'lib/rbs/ast/declarations.rb', line 308

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



310
311
312
# File 'lib/rbs/ast/declarations.rb', line 310

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



309
310
311
# File 'lib/rbs/ast/declarations.rb', line 309

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



305
306
307
# File 'lib/rbs/ast/declarations.rb', line 305

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



307
308
309
# File 'lib/rbs/ast/declarations.rb', line 307

def type
  @type
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



306
307
308
# File 'lib/rbs/ast/declarations.rb', line 306

def type_params
  @type_params
end

Instance Method Details

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



321
322
323
324
325
326
# File 'lib/rbs/ast/declarations.rb', line 321

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

#hashObject



330
331
332
# File 'lib/rbs/ast/declarations.rb', line 330

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

#to_json(state = _ = nil) ⇒ Object



334
335
336
337
338
339
340
341
342
343
344
# File 'lib/rbs/ast/declarations.rb', line 334

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