123456789_123456789_123456789_123456789_123456789_

Class: PrettyPrint::Group

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
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 #group

This class is intended for internal use of the ::PrettyPrint buffers.

Class Method Summary

Instance Attribute Summary

Constructor Details

.new(depth) ⇒ Group

Create a Group object

Arguments:

  • #depth - this group’s relation to previous groups

[ GitHub ]

  
# File 'lib/prettyprint.rb', line 401

def initialize(depth)
  @depth = depth
  @breakables = []
  @break = false
end

Instance Attribute Details

#break (readonly)

Makes a break for this Group, and returns true

[ GitHub ]

  
# File 'lib/prettyprint.rb', line 414

def break
  @break = true
end

#break?Boolean (readonly)

Boolean of whether this Group has made a break

[ GitHub ]

  
# File 'lib/prettyprint.rb', line 419

def break?
  @break
end

#breakables (readonly)

Array to hold the Breakable objects for this Group

[ GitHub ]

  
# File 'lib/prettyprint.rb', line 411

attr_reader :breakables

#depth (readonly)

This group’s relation to previous groups

[ GitHub ]

  
# File 'lib/prettyprint.rb', line 408

attr_reader :depth

#first?Boolean (readonly)

Boolean of whether this Group has been queried for being first

This is used as a predicate, and ought to be called first.

[ GitHub ]

  
# File 'lib/prettyprint.rb', line 426

def first?
  if defined? @first
    false
  else
    @first = false
    true
  end
end