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.



3307
3308
3309
# File 'lib/syntax_tree/node.rb', line 3307

def initialize(comments)
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment ]

the list of comments this list represents



3305
3306
3307
# File 'lib/syntax_tree/node.rb', line 3305

def comments
  @comments
end

Instance Method Details

#pretty_print(q) ⇒ Object



3311
3312
3313
3314
3315
3316
# File 'lib/syntax_tree/node.rb', line 3311

def pretty_print(q)
  return if comments.empty?

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