Class: SyntaxTree::Comment::List

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(comments) ⇒ List

Returns a new instance of List.



3409
3410
3411
# File 'lib/syntax_tree/node.rb', line 3409

def initialize(comments)
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment ]

the list of comments this list represents



3407
3408
3409
# File 'lib/syntax_tree/node.rb', line 3407

def comments
  @comments
end

Instance Method Details

#pretty_print(q) ⇒ Object



3413
3414
3415
3416
3417
3418
# File 'lib/syntax_tree/node.rb', line 3413

def pretty_print(q)
  return if comments.empty?

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