Class: PrettyPrint::LineSuffix
- Inherits:
-
Object
- Object
- PrettyPrint::LineSuffix
- 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.
Constant Summary collapse
- DEFAULT_PRIORITY =
1
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
-
#initialize(priority: DEFAULT_PRIORITY, contents: []) ⇒ LineSuffix
constructor
A new instance of LineSuffix.
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(priority: DEFAULT_PRIORITY, contents: []) ⇒ LineSuffix
Returns a new instance of LineSuffix.
220 221 222 223 |
# File 'lib/syntax_tree/prettyprint.rb', line 220 def initialize(priority: DEFAULT_PRIORITY, contents: []) @priority = priority @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
218 219 220 |
# File 'lib/syntax_tree/prettyprint.rb', line 218 def contents @contents end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
218 219 220 |
# File 'lib/syntax_tree/prettyprint.rb', line 218 def priority @priority end |
Instance Method Details
#pretty_print(q) ⇒ Object
225 226 227 228 229 |
# File 'lib/syntax_tree/prettyprint.rb', line 225 def pretty_print(q) q.group(2, "line-suffix([", "])") do q.seplist(contents) { |content| q.pp(content) } end end |