Module: RBS::AST::Members::Attribute

Includes:
_HashEqual
Included in:
AttrAccessor, AttrReader, AttrWriter
Defined in:
lib/rbs/ast/members.rb,
sig/members.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#annotationsArray[Annotation] (readonly)

Returns the value of attribute annotations.

Returns:



265
266
267
# File 'lib/rbs/ast/members.rb', line 265

def annotations
  @annotations
end

#commentComment? (readonly)

Returns the value of attribute comment.

Returns:



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

def comment
  @comment
end

#ivar_nameSymbol, ... (readonly)

Returns the value of attribute ivar_name.

Returns:

  • (Symbol, false, nil)


264
265
266
# File 'lib/rbs/ast/members.rb', line 264

def ivar_name
  @ivar_name
end

#kindkind (readonly)

Returns the value of attribute kind.

Returns:



263
264
265
# File 'lib/rbs/ast/members.rb', line 263

def kind
  @kind
end

#locationloc? (readonly)

Returns the value of attribute location.

Returns:

  • (loc, nil)


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

def location
  @location
end

#nameSymbol (readonly)

Returns the value of attribute name.

Returns:

  • (Symbol)


261
262
263
# File 'lib/rbs/ast/members.rb', line 261

def name
  @name
end

#typeTypes::t (readonly)

Returns the value of attribute type.

Returns:

  • (Types::t)


262
263
264
# File 'lib/rbs/ast/members.rb', line 262

def type
  @type
end

#visibilityvisibility? (readonly)

Returns the value of attribute visibility.

Returns:



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

def visibility
  @visibility
end

Instance Method Details

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



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

def ==(other)
  other.is_a?(self.class) &&
    other.name == name &&
    other.type == type &&
    other.ivar_name == ivar_name &&
    other.kind == kind &&
    other.visibility == visibility
end

#hashObject



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

def hash
  name.hash ^ type.hash ^ ivar_name.hash ^ kind.hash ^ visibility.hash
end

#initialize(name:, type:, ivar_name:, kind:, annotations:, location:, comment:, visibility: nil) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:

  • name: (Symbol)
  • type: (Types::t)
  • ivar_name: (Symbol, false, nil)
  • kind: (kind)
  • annotations: (Array[Annotation])
  • location: (loc, nil)
  • comment: (Comment, nil)
  • visibility: (visibility, nil) (defaults to: nil)

Returns:

  • (Attribute)

    a new instance of Attribute



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

def initialize(name:, type:, ivar_name:, kind:, annotations:, location:, comment:, visibility: nil)
  @name = name
  @type = type
  @ivar_name = ivar_name
  @annotations = annotations
  @location = location
  @comment = comment
  @kind = kind
  @visibility = visibility
end

#update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: self.kind, annotations: self.annotations, location: self.location, comment: self.comment, visibility: self.visibility) ⇒ instance

Parameters:

  • name: (Symbol) (defaults to: self.name)
  • type: (Types::t) (defaults to: self.type)
  • ivar_name: (Symbol, false, nil) (defaults to: self.ivar_name)
  • kind: (kind) (defaults to: self.kind)
  • annotations: (Array[Annotation]) (defaults to: self.annotations)
  • location: (loc, nil) (defaults to: self.location)
  • comment: (Comment, nil) (defaults to: self.comment)
  • visibility: (visibility, nil) (defaults to: self.visibility)

Returns:

  • (instance)


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

def update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: self.kind, annotations: self.annotations, location: self.location, comment: self.comment, visibility: self.visibility)
  klass = _ = self.class
  klass.new(
    name: name,
    type: type,
    ivar_name: ivar_name,
    kind: kind,
    annotations: annotations,
    location: location,
    comment: comment,
    visibility: visibility
  )
end