Class: RBI::NodeWithComments

Inherits:
Node
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rewriters/merge_trees.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

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.



88
89
90
91
# File 'lib/rbi/model.rb', line 88

def initialize(loc: nil, comments: [])
  super(loc: loc)
  @comments = comments
end

Instance Attribute Details

#commentsObject

Returns the value of attribute comments.



85
86
87
# File 'lib/rbi/model.rb', line 85

def comments
  @comments
end

Instance Method Details

#merge_with(other) ⇒ Object



304
305
306
307
308
309
# File 'lib/rbi/rewriters/merge_trees.rb', line 304

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

Returns:

  • (Boolean)


149
150
151
# File 'lib/rbi/printer.rb', line 149

def oneline?
  comments.empty?
end