Class: RBI::Comment

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

Direct Known Subclasses

BlankLine

Instance Attribute Summary collapse

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from Node

#compatible_with?, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string

Constructor Details

#initialize(text, loc: nil) ⇒ Comment

Returns a new instance of Comment.



57
58
59
60
# File 'lib/rbi/model.rb', line 57

def initialize(text, loc: nil)
  super(loc: loc)
  @text = text
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



54
55
56
# File 'lib/rbi/model.rb', line 54

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



63
64
65
66
# File 'lib/rbi/model.rb', line 63

def ==(other)
  return false unless other.is_a?(Comment)
  text == other.text
end

#accept_printer(v) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/rbi/printer.rb', line 167

def accept_printer(v)
  lines = text.lines

  if lines.empty?
    v.printl("#")
  end

  lines.each do |line|
    text = line.strip
    v.printt("#")
    v.print(" #{text}") unless text.empty?
    v.printn
  end
end