Class: RBI::TypeMember

Inherits:
NodeWithComments show all
Includes:
Indexable
Defined in:
lib/rbi/index.rb,
lib/rbi/model.rb

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#annotations, #comments?, #merge_with, #version_requirements

Methods inherited from Node

#compatible_with?, #detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string

Constructor Details

#initialize(name, value, loc: nil, comments: nil, &block) ⇒ TypeMember

Returns a new instance of TypeMember.

Signature:

  • (String name, String value, ?loc: Loc?, ?comments: Array[Comment]?) ?{ (TypeMember node) -> void } -> void



1372
1373
1374
1375
1376
1377
# File 'lib/rbi/model.rb', line 1372

def initialize(name, value, loc: nil, comments: nil, &block)
  super(loc: loc, comments: comments)
  @name = name.to_s #: String
  @value = value
  block&.call(self)
end

Instance Attribute Details

#nameObject (readonly)

Signature:

  • String



1369
1370
1371
# File 'lib/rbi/model.rb', line 1369

def name
  @name
end

#valueObject (readonly)

Signature:

  • String



1369
1370
1371
# File 'lib/rbi/model.rb', line 1369

def value
  @value
end

Instance Method Details

#fully_qualified_nameObject

Signature:

  • -> String



1380
1381
1382
1383
1384
# File 'lib/rbi/model.rb', line 1380

def fully_qualified_name
  return name if name.start_with?("::")

  "#{parent_scope&.fully_qualified_name}::#{name}"
end

#index_idsObject

Signature:

  • -> Array[String]



174
175
176
# File 'lib/rbi/index.rb', line 174

def index_ids
  [to_s]
end

#to_sObject

Signature:

  • -> String



1388
1389
1390
# File 'lib/rbi/model.rb', line 1388

def to_s
  fully_qualified_name
end