Class: Layout::Table

Inherits:
Entity show all
Includes:
Enumerable

Overview

A Table is a series of rows and columns that holds data.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
doc = Layout::Document.open("C:/path/to/document.layout")
doc.add_entity(table, doc.layers.first, doc.pages.first)
anchor_type = Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT
start_point = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Hello LayOut", start_point, anchor_type)
table[1, 1].data = text

Version:

  • LayOut 2018

Instance Method Summary # collapse

Methods inherited from Entity

#==, #bounds, #document, #drawing_bounds, #group, #layer_instance, #locked=, #locked?, #move_to_group, #move_to_layer, #on_shared_layer?, #page, #style, #style=, #transform!, #transformation, #untransformed_bounds, #untransformed_bounds=

Constructor Details

#initialize(bounds, rows, columns) ⇒ Layout::Table

The #initialize method creates a Layout::Table with a specified size, and a specified number of rows and columns.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)

Parameters:

Raises:

  • (ArgumentError)

    if rows is less than 1

  • (ArgumentError)

    if columns is less than 1

  • (ArgumentError)

    if bounds is zero size

Version:

  • LayOut 2018

Instance Method Details

#[](row_index, column_index) ⇒ Layout::TableCell

The #[] method returns the Layout::TableCell at the specified row and column.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
cell = table[1, 2]

Parameters:

  • row_index (Integer)
  • column_index (Integer)

Returns:

Raises:

  • (IndexError)

    if row_index or column_index are not a valid indices for the Layout::Table

Version:

  • LayOut 2018

#dimensionsArray(Integer, Integer)

The #dimensions method returns the number of rows and columns in a Layout::Table.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
r, c = table.dimensions

Returns:

  • (Array(Integer, Integer))

    The first value is the number of rows; the second, the number of columns.

Version:

  • LayOut 2018

#each {|cell| ... } ⇒ Object

The #each method iterates in column major order through all of the cells in the Layout::Table.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.each { |cell|
  puts cell.data.plain_text
}

Yield Parameters:

Version:

  • LayOut 2018

#entitiesLayout::Entities

The #entities method creates and returns the Entities that represent the Layout::Table in its exploded form.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
entities = table.entities

Returns:

Version:

  • LayOut 2018

#get_column(index) ⇒ Layout::TableColumn

The #get_column method returns the Layout::TableColumn at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table_column = table.get_column(2)

Parameters:

  • index (Integer)

Returns:

Raises:

  • (IndexError)

    if index is not a valid index for the Layout::Table

Version:

  • LayOut 2018

#get_row(index) ⇒ Layout::TableRow

The #get_row method returns the Layout::TableRow at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table_row = table.get_row(2)

Parameters:

  • index (Integer)

Returns:

Raises:

  • (IndexError)

    if index is not a valid index for the Layout::Table

Version:

  • LayOut 2018

#insert_column(index) ⇒ Object

The #insert_column method inserts a new column at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.insert_column(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018

#insert_row(index) ⇒ Object

The #insert_row method inserts a new row at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.insert_row(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018

#merge(start_row, start_column, end_row, end_column) ⇒ Object

The #merge method merges a range of cells within a Layout::Table. Only cells which are not already merged can be merged.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.merge(1, 1, 2, 2)

Parameters:

  • start_row (Integer)
  • start_column (Integer)
  • end_row (Integer)
  • end_column (Integer)

Raises:

Version:

  • LayOut 2018

#remove_column(index) ⇒ Object

The #remove_column method removes the column at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.remove_column(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018

#remove_row(index) ⇒ Object

The #remove_row method removes the row at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.remove_row(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018