Class: SyntaxTree::Comment::List

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(comments) ⇒ List

Returns a new instance of List.



3915
3916
3917
# File 'lib/syntax_tree.rb', line 3915

def initialize(comments)
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment ]

the list of comments this list represents



3913
3914
3915
# File 'lib/syntax_tree.rb', line 3913

def comments
  @comments
end

Instance Method Details

#pretty_print(q) ⇒ Object



3919
3920
3921
3922
3923
3924
# File 'lib/syntax_tree.rb', line 3919

def pretty_print(q)
  return if comments.empty?

  q.breakable
  q.group(2, "(", ")") { q.seplist(comments) { |comment| q.pp(comment) } }
end