Class: RBI::TEnumBlock

Inherits:
NodeWithComments show all
Extended by:
T::Sig
Includes:
Indexable
Defined in:
lib/rbi/index.rb,
lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.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, #version_requirements

Methods inherited from Node

#compatible_with?, #detach, #parent_conflict_tree, #parent_scope, #print, #replace, #satisfies_version?, #string

Constructor Details

#initialize(names = [], loc: nil, comments: [], &block) ⇒ TEnumBlock

Returns a new instance of TEnumBlock.



1350
1351
1352
1353
1354
# File 'lib/rbi/model.rb', line 1350

def initialize(names = [], loc: nil, comments: [], &block)
  super(loc: loc, comments: comments)
  @names = names
  block&.call(self)
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



1340
1341
1342
# File 'lib/rbi/model.rb', line 1340

def names
  @names
end

Instance Method Details

#<<(name) ⇒ Object



1362
1363
1364
# File 'lib/rbi/model.rb', line 1362

def <<(name)
  @names << name
end

#empty?Boolean

Returns:

  • (Boolean)


1357
1358
1359
# File 'lib/rbi/model.rb', line 1357

def empty?
  names.empty?
end

#index_idsObject



223
224
225
# File 'lib/rbi/index.rb', line 223

def index_ids
  [to_s]
end

#merge_with(other) ⇒ Object



558
559
560
561
562
563
564
565
# File 'lib/rbi/rewriters/merge_trees.rb', line 558

def merge_with(other)
  return unless other.is_a?(TEnumBlock)

  super
  other.names.each do |name|
    names << name unless names.include?(name)
  end
end

#to_sObject



1367
1368
1369
# File 'lib/rbi/model.rb', line 1367

def to_s
  "#{parent_scope&.fully_qualified_name}.enums"
end