Class: RBI::Include

Inherits:
Mixin show all
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 NodeWithComments

#annotations, #merge_with, #version_requirements

Methods inherited from Node

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

Constructor Details

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

: (String name, *String names, ?loc: Loc?, ?comments: Array) ?{ (Include node) -> void } -> void



682
683
684
685
# File 'lib/rbi/model.rb', line 682

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

: (Node other) -> bool

Returns:

  • (Boolean)


471
472
473
# File 'lib/rbi/rewriters/merge_trees.rb', line 471

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

#index_idsObject

: -> Array



129
130
131
# File 'lib/rbi/index.rb', line 129

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

#to_sObject

: -> String



689
690
691
# File 'lib/rbi/model.rb', line 689

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