Class: RBI::NodeWithComments
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rewriters/merge_trees.rb
Direct Known Subclasses
Attr, Const, Helper, Method, Mixin, Param, TEnumBlock, TStructField, Tree, TypeMember
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(loc: nil, comments: []) ⇒ NodeWithComments
constructor
A new instance of NodeWithComments.
- #merge_with(other) ⇒ Object
- #oneline? ⇒ Boolean
Methods inherited from Node
#accept_printer, #compatible_with?, #detach, #group_kind, #parent_conflict_tree, #parent_scope, #print, #replace, #string
Constructor Details
#initialize(loc: nil, comments: []) ⇒ NodeWithComments
Returns a new instance of NodeWithComments.
79 80 81 82 |
# File 'lib/rbi/model.rb', line 79 def initialize(loc: nil, comments: []) super(loc: loc) @comments = comments end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
76 77 78 |
# File 'lib/rbi/model.rb', line 76 def comments @comments end |
Instance Method Details
#merge_with(other) ⇒ Object
275 276 277 278 279 280 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 275 def merge_with(other) return unless other.is_a?(NodeWithComments) other.comments.each do |comment| comments << comment unless comments.include?(comment) end end |
#oneline? ⇒ Boolean
149 150 151 |
# File 'lib/rbi/printer.rb', line 149 def oneline? comments.empty? end |