123456789_123456789_123456789_123456789_123456789_

Class: Layout::Layers

Relationships
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object

Overview

The Layers class is a container class for all layers in a Document.

Examples:

# Grab a handle to the currently active document's layers
doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers

# From here, we can add layers to or remove them from the document
layers.add("New Layer")
layers.remove(layers[0])

Version:

  • LayOut 2018

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#activeLayout::Layer (rw)

The #active method returns the active Layer in the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layer = doc.layers.active

Version:

  • LayOut 2018

#active=(layer) ⇒ Layout::Layer (rw) #active=(index) ⇒ Layout::Layer

The #active= method sets the active Layer that will be displayed the next time the Document is opened. This value will change whenever the Layer is changed in the Document in LayOut.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.active = layers[0]

Overloads:

  • #active=(layer) ⇒ Layout::Layer

    Parameters:

    Raises:

    • (ArgumentError)

      if layer does not belong to the Document

    • (ArgumentError)

      if layer is locked or hidden on the current Page

  • #active=(index) ⇒ Layout::Layer

    Parameters:

    • index (Integer)

      The index of Layer the to set as the initial one

    Raises:

    • (ArgumentError)

      if index is out of range

    • (ArgumentError)

      if the Layer is locked or hidden on the current Page

Version:

  • LayOut 2018

Instance Method Details

#[](index) ⇒ Layout::Layer

The #[] method returns a value from the array of Layers.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layer = layers[2]

Parameters:

  • index (Integer)

    The index of the Layer to return.

Raises:

  • (IndexError)

    if index is out of range

Version:

  • LayOut 2018

#add(shared = false) ⇒ Layout::Layer #add(name, shared = false) ⇒ Layout::Layer

The #add method adds a new Layer to the Document. The newly added Layer will be the last one in the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
new_layer = doc.layers.add

Overloads:

  • #add(shared = false) ⇒ Layout::Layer

    Parameters:

    • shared (Boolean) (defaults to: false)

      true to make the Layer shared, false for non-shared.

    Returns:

  • #add(name, shared = false) ⇒ Layout::Layer

    Parameters:

    • name (String)

      The name for the new layer.

    • shared (Boolean) (defaults to: false)

      true to make the Layer shared, false for non-shared.

    Returns:

Version:

  • LayOut 2018

#each {|layer| ... }

Note:

Don’t remove content from this collection while iterating over it with #each. This would change the size of the collection and cause elements to be skipped as the indices change. Instead copy the current collection to an array using to_a and then use each on the array, when removing content.

The #each method iterates through all of the Layers.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.each { |layer|
  puts layer.name
}

Yield Parameters:

Version:

  • LayOut 2018

#index(layer) ⇒ Integer?

The #index method returns the index of the Layer, or nil if it doesn’t exist in the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layer_index = layers.index(layers.first) # Returns 0

Parameters:

Version:

  • LayOut 2018

#lengthInteger Also known as: #size

The #length method returns the number of Layers.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
num_layers = layers.length

Version:

  • LayOut 2018

#remove(layer, delete_entities = false) #remove(index, delete_entities = false)

The #remove method deletes the given Layer from the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.remove(layers[0])

Overloads:

  • #remove(layer, delete_entities = false)

    Parameters:

    • layer (Layout::Layer)

      The Layer to be removed

    • delete_entities (Boolean) (defaults to: false)

      Whether the Entitys on the deleted Layer should be deleted as well

    Raises:

  • #remove(index, delete_entities = false)

    Parameters:

    • index (Integer)

      The index of the Layer to be removed

    • delete_entities (Boolean) (defaults to: false)

      Whether the Entitys on the deleted Layer should be deleted as well

    Raises:

    • (IndexError)

      if index is out of range

    • (ArgumentError)

      if the Layer is the only one in the Document

Version:

  • LayOut 2018

#reorder(layer, new_index) #reorder(index, new_index)

The #reorder method moves a Layer to a different index within the Document‘s list of layers. This will move the Layer such that its new index becomes new_index.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.reorder(layers[1], 3)

Overloads:

  • #reorder(layer, new_index)

    Parameters:

    Raises:

    • (ArgumentError)

      if the Layer is not in the Document

    • (IndexError)

      if new_index is out of range

  • #reorder(index, new_index)

    Parameters:

    • index (Integer)

      The index of the Layer to be reordered

    • new_index (Integer)

      The index to put the Layer at

    Raises:

    • (IndexError)

      if index or new_index are out of range

Version:

  • LayOut 2018

#size

Alias for #length.