Class: RBI::Mixin
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Mixin
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rewriters/merge_trees.rb
Overview
Mixins
Direct Known Subclasses
Instance Attribute Summary collapse
-
#names ⇒ Object
Returns the value of attribute names.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #accept_printer(v) ⇒ Object
- #compatible_with?(other) ⇒ Boolean
-
#initialize(name, *names, loc: nil, comments: []) ⇒ Mixin
constructor
A new instance of Mixin.
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, *names, loc: nil, comments: []) ⇒ Mixin
Returns a new instance of Mixin.
562 563 564 565 |
# File 'lib/rbi/model.rb', line 562 def initialize(name, *names, loc: nil, comments: []) super(loc: loc, comments: comments) @names = T.let([name, *names], T::Array[String]) end |
Instance Attribute Details
#names ⇒ Object
Returns the value of attribute names.
559 560 561 |
# File 'lib/rbi/model.rb', line 559 def names @names end |
Instance Method Details
#accept_printer(v) ⇒ Object
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/rbi/printer.rb', line 474 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) case self when Include v.printt("include") when Extend v.printt("extend") when MixesInClassMethods v.printt("mixes_in_class_methods") end v.printn(" #{names.join(", ")}") end |
#compatible_with?(other) ⇒ Boolean
410 411 412 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 410 def compatible_with?(other) other.is_a?(Mixin) && names == other.names end |