### Home Classes Methods

### In Files

- lib/prawn/layout/grid.rb

### Parent

Object

### Methods

- ::new
- #bottom
- #bottom_left
- #bottom_right
- #bounding_box
- #gutter
- #height
- #left
- #name
- #right
- #show
- #top
- #top_left
- #top_right
- #total_height
- #width

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# Prawn::Document::GridBox

A Box is a class that represents a bounded area of a page. A Grid object has methods that allow easy access to the coordinates of its corners, which can be plugged into most existing prawnmethods.

@private

### Attributes

pdf[R]

### Public Class Methods

new(pdf, i, j) click to toggle source

    # File lib/prawn/layout/grid.rb, line 102
    def initialize(pdf, i, j)
      @pdf = pdf
      @i = i
      @j = j
    end

### Public Instance Methods

bottom() click to toggle source

y-coordinate of the bottom

    # File lib/prawn/layout/grid.rb, line 151
    def bottom
      @bottom ||= top - height
    end

bottom_left() click to toggle source

x,y coordinates of bottom left corner

    # File lib/prawn/layout/grid.rb, line 166
    def bottom_left
      [left, bottom]
    end

bottom_right() click to toggle source

x,y coordinates of bottom right corner

    # File lib/prawn/layout/grid.rb, line 171
    def bottom_right
      [right, bottom]
    end

bounding_box(&blk) click to toggle source

Creates a standard bounding box based on the grid box.

    # File lib/prawn/layout/grid.rb, line 176
    def bounding_box(&blk)
      pdf.bounding_box(top_left, :width => width, :height => height, &blk)
    end

gutter() click to toggle source

Width of the gutter

    # File lib/prawn/layout/grid.rb, line 131
    def gutter
      grid.gutter.to_f
    end

height() click to toggle source

Height of a box

    # File lib/prawn/layout/grid.rb, line 126
    def height
      grid.row_height.to_f
    end

left() click to toggle source

x-coordinate of left side

    # File lib/prawn/layout/grid.rb, line 136
    def left
      @left ||= (width + grid.column_gutter) * @j.to_f
    end

name() click to toggle source

Mostly diagnostic method that outputs the name of a box as col_num, row_num

    # File lib/prawn/layout/grid.rb, line 111
    def name
      "#{@i.to_s},#{@j.to_s}"
    end

right() click to toggle source

x-coordinate of right side

    # File lib/prawn/layout/grid.rb, line 141
    def right
      @right ||= left + width
    end

show(grid_color = "CCCCCC") click to toggle source

Diagnostic method

    # File lib/prawn/layout/grid.rb, line 181
    def show(grid_color = "CCCCCC")
      self.bounding_box do
        original_stroke_color = pdf.stroke_color

        pdf.stroke_color = grid_color
        pdf.text self.name
        pdf.stroke_bounds

        pdf.stroke_color = original_stroke_color
      end
    end

top() click to toggle source

y-coordinate of the top

    # File lib/prawn/layout/grid.rb, line 146
    def top
      @top ||= total_height - ((height + grid.row_gutter) * @i.to_f)
    end

top_left() click to toggle source

x,y coordinates of top left corner

    # File lib/prawn/layout/grid.rb, line 156
    def top_left
      [left, top]
    end

top_right() click to toggle source

x,y coordinates of top right corner

    # File lib/prawn/layout/grid.rb, line 161
    def top_right
      [right, top]
    end

total_height() click to toggle source

:nodoc

    # File lib/prawn/layout/grid.rb, line 116
    def total_height
      pdf.bounds.height.to_f
    end

width() click to toggle source

Width of a box

    # File lib/prawn/layout/grid.rb, line 121
    def width
      grid.column_width.to_f
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.