Class: RBI::Extend

Inherits:
Mixin 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

Attributes inherited from Mixin

#names

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from Mixin

#accept_printer

Methods inherited from NodeWithComments

#annotations, #merge_with, #oneline?

Methods inherited from Node

#accept_printer, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string

Constructor Details

#initialize(name, *names, loc: nil, comments: [], &block) ⇒ Extend

Returns a new instance of Extend.



820
821
822
823
# File 'lib/rbi/model.rb', line 820

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

Instance Method Details

#compatible_with?(other) ⇒ Boolean

Returns:

  • (Boolean)


492
493
494
# File 'lib/rbi/rewriters/merge_trees.rb', line 492

def compatible_with?(other)
  other.is_a?(Extend) && super
end

#index_idsObject



139
140
141
# File 'lib/rbi/index.rb', line 139

def index_ids
  names.map { |name| "#{parent_scope&.fully_qualified_name}.extend(#{name})" }
end

#to_sObject



826
827
828
# File 'lib/rbi/model.rb', line 826

def to_s
  "#{parent_scope&.fully_qualified_name}.extend(#{names.join(", ")})"
end