Class: RBI::Helper
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Helper
- Extended by:
- T::Helpers, T::Sig
- Includes:
- Indexable
- Defined in:
- lib/rbi/model.rb,
lib/rbi/index.rb,
lib/rbi/printer.rb,
lib/rbi/rewriters/merge_trees.rb
Overview
Sorbet’s misc.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #accept_printer(v) ⇒ Object
- #compatible_with?(other) ⇒ Boolean
- #index_ids ⇒ Object
-
#initialize(name, loc: nil, comments: [], &block) ⇒ Helper
constructor
A new instance of Helper.
- #to_s ⇒ Object
Methods inherited from NodeWithComments
Methods inherited from Node
#detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #replace, #string
Constructor Details
#initialize(name, loc: nil, comments: [], &block) ⇒ Helper
Returns a new instance of Helper.
1183 1184 1185 1186 1187 |
# File 'lib/rbi/model.rb', line 1183 def initialize(name, loc: nil, comments: [], &block) super(loc: loc, comments: comments) @name = name block&.call(self) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
1173 1174 1175 |
# File 'lib/rbi/model.rb', line 1173 def name @name end |
Instance Method Details
#accept_printer(v) ⇒ Object
696 697 698 699 700 701 702 703 |
# File 'lib/rbi/printer.rb', line 696 def accept_printer(v) previous_node = v.previous_node v.printn if previous_node && (!previous_node.oneline? || !oneline?) v.printl("# #{loc}") if loc && v.print_locs v.visit_all(comments) v.printl("#{name}!") end |
#compatible_with?(other) ⇒ Boolean
486 487 488 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 486 def compatible_with?(other) other.is_a?(Helper) && name == other.name end |
#index_ids ⇒ Object
152 153 154 |
# File 'lib/rbi/index.rb', line 152 def index_ids [to_s] end |
#to_s ⇒ Object
1190 1191 1192 |
# File 'lib/rbi/model.rb', line 1190 def to_s "#{parent_scope&.fully_qualified_name}.#{name}!" end |