Class: RBI::Helper

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

Overview

Sorbet’s misc.

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

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

Constructor Details

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

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



1192
1193
1194
1195
1196
# File 'lib/rbi/model.rb', line 1192

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

Instance Attribute Details

#nameObject (readonly)

: String



1189
1190
1191
# File 'lib/rbi/model.rb', line 1189

def name
  @name
end

Instance Method Details

#compatible_with?(other) ⇒ Boolean

: (Node other) -> bool

Returns:

  • (Boolean)


540
541
542
# File 'lib/rbi/rewriters/merge_trees.rb', line 540

def compatible_with?(other)
  other.is_a?(Helper) && name == other.name
end

#index_idsObject

: -> Array



164
165
166
# File 'lib/rbi/index.rb', line 164

def index_ids
  [to_s]
end

#to_sObject

: -> String



1200
1201
1202
# File 'lib/rbi/model.rb', line 1200

def to_s
  "#{parent_scope&.fully_qualified_name}.#{name}!"
end