Class: PrettyPrint::LineSuffix

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

Overview

A node in the print tree that has its own special buffer for implementing content that should flush before any newline.

Useful for implementating trailing content, as it’s not always practical to constantly check where the line ends to avoid accidentally printing some content after a line suffix node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents: []) ⇒ LineSuffix

Returns a new instance of LineSuffix.



218
219
220
# File 'lib/syntax_tree/prettyprint.rb', line 218

def initialize(contents: [])
  @contents = contents
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



216
217
218
# File 'lib/syntax_tree/prettyprint.rb', line 216

def contents
  @contents
end

Instance Method Details

#pretty_print(q) ⇒ Object



222
223
224
225
226
# File 'lib/syntax_tree/prettyprint.rb', line 222

def pretty_print(q)
  q.group(2, "line-suffix([", "])") do
    q.seplist(contents) { |content| q.pp(content) }
  end
end