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.



3620
3621
3622
# File 'lib/syntax_tree.rb', line 3620

def initialize(comments)
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment ]

the list of comments this list represents



3618
3619
3620
# File 'lib/syntax_tree.rb', line 3618

def comments
  @comments
end

Instance Method Details

#pretty_print(q) ⇒ Object



3624
3625
3626
3627
3628
3629
# File 'lib/syntax_tree.rb', line 3624

def pretty_print(q)
  return if comments.empty?

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