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

EmptyComment

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, #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



158
159
160
161
162
163
# File 'lib/rbi/printer.rb', line 158

def accept_printer(v)
  text = self.text.strip
  v.printt("#")
  v.print(" #{text}") unless text.empty?
  v.printn
end