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.



60
61
62
63
# File 'lib/rbi/model.rb', line 60

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

Instance Attribute Details

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



66
67
68
69
70
# File 'lib/rbi/model.rb', line 66

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

  text == other.text
end

#accept_printer(v) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/rbi/printer.rb', line 197

def accept_printer(v)
  lines = text.lines

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

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