Class: PrettyPrint::Group
- Inherits:
-
Object
- Object
- PrettyPrint::Group
- Defined in:
- lib/prettyprint.rb
Overview
The Group class is used for making indentation easier.
While this class does neither the breaking into newlines nor indentation, it is used in a stack (as well as a queue) within PrettyPrint, to group objects.
For information on using groups, see PrettyPrint#group
This class is intended for internal use of the PrettyPrint buffers.
Instance Attribute Summary collapse
-
#breakables ⇒ Object
readonly
Array to hold the Breakable objects for this Group.
-
#depth ⇒ Object
readonly
This group’s relation to previous groups.
Instance Method Summary collapse
-
#break ⇒ Object
Makes a break for this Group, and returns true.
-
#break? ⇒ Boolean
Boolean of whether this Group has made a break.
-
#first? ⇒ Boolean
Boolean of whether this Group has been queried for being first.
-
#initialize(depth) ⇒ Group
constructor
Create a Group object.
Constructor Details
#initialize(depth) ⇒ Group
Create a Group object
Arguments:
-
depth
- this group’s relation to previous groups
399 400 401 402 403 |
# File 'lib/prettyprint.rb', line 399 def initialize(depth) @depth = depth @breakables = [] @break = false end |
Instance Attribute Details
#breakables ⇒ Object (readonly)
Array to hold the Breakable objects for this Group
409 410 411 |
# File 'lib/prettyprint.rb', line 409 def breakables @breakables end |
#depth ⇒ Object (readonly)
This group’s relation to previous groups
406 407 408 |
# File 'lib/prettyprint.rb', line 406 def depth @depth end |
Instance Method Details
#break ⇒ Object
Makes a break for this Group, and returns true
412 413 414 |
# File 'lib/prettyprint.rb', line 412 def break @break = true end |
#break? ⇒ Boolean
Boolean of whether this Group has made a break
417 418 419 |
# File 'lib/prettyprint.rb', line 417 def break? @break end |
#first? ⇒ Boolean
Boolean of whether this Group has been queried for being first
This is used as a predicate, and ought to be called first.
424 425 426 427 428 429 430 431 |
# File 'lib/prettyprint.rb', line 424 def first? if defined? @first false else @first = false true end end |