Class: Layout::AutoTextDefinitions

Inherits:
Object
  • Object
show all
Includes:
Enumerable

Overview

The AutoTextDefinitions class is a container class for all AutoTextDefinitions in a Document.

Examples:

# Grab a handle to an existing LayOut document's auto text definitions.
doc = Layout::Document.open("C:/path/to/document.layout")
auto_texts = doc.auto_text_definitions

# From here, we can add auto text definitions to or remove them from the
# document.
auto_texts.add("PageNum", Layout::AutoTextDefinition::TYPE_PAGE_NUM)
auto_texts.remove("PageNum")

Version:

  • LayOut 2018

Instance Method Summary # collapse

Instance Method Details

#[](index) ⇒ Layout::AutoTextDefinition #[](name) ⇒ Layout::AutoTextDefinition

The #[] method returns a value from the array of Layout::AutoTextDefinitions.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
auto_texts = doc.auto_text_definitions
auto_text = auto_texts[2]

Overloads:

Raises:

  • (IndexError)

    if index is out of range

Version:

  • LayOut 2018

#add(name, type) ⇒ Layout::AutoTextDefinition

The #add method adds an Layout::AutoTextDefinition to the Document.

The type can be one of the following values:

Layout::AutoTextDefinition::TYPE_FILE
Layout::AutoTextDefinition::TYPE_PAGE_NAME
Layout::AutoTextDefinition::TYPE_PAGE_NUMBER
Layout::AutoTextDefinition::TYPE_CUSTOM_TEXT
Layout::AutoTextDefinition::TYPE_DATE_CURRENT
Layout::AutoTextDefinition::TYPE_DATE_CREATED
Layout::AutoTextDefinition::TYPE_DATE_MODIFIED
Layout::AutoTextDefinition::TYPE_DATE_PUBLISHED

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
doc.auto_text_definitions.add("current date",
   Layout::AutoTextDefinition::TYPE_DATE_CURRENT);

Parameters:

  • name (String)
  • type (Integer)

Returns:

Raises:

  • (ArgumentError)

    if type is not a valid auto text type, or is mandatory.

Version:

  • LayOut 2018

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

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 Layout::AutoTextDefinitions.

Examples:

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

Yield Parameters:

Version:

  • LayOut 2018

#index(auto_text) ⇒ Integer? #index(name) ⇒ Integer?

The #index method returns the index of the Layout::AutoTextDefinition, or nil if it doesn't exist in the Document.

Examples:

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

Overloads:

Version:

  • LayOut 2018

#lengthInteger Also known as: size

The #length method returns the number of Layout::AutoTextDefinitions.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
auto_texts = doc.auto_text_definitions
num_auto_texts = auto_texts.length

Returns:

  • (Integer)

Version:

  • LayOut 2018

#remove(definition, convert_tags_to_text = true) ⇒ Object #remove(name, convert_tags_to_text = true) ⇒ Object #remove(index, convert_tags_to_text = true) ⇒ Object

The #remove method removes an Layout::AutoTextDefinition from the Document.

The Layout::AutoTextDefinition must be one of the following types:

Layout::AutoTextDefinition::TYPE_FILE
Layout::AutoTextDefinition::TYPE_PAGE_NAME
Layout::AutoTextDefinition::TYPE_PAGE_NUMBER
Layout::AutoTextDefinition::TYPE_CUSTOM_TEXT
Layout::AutoTextDefinition::TYPE_DATE_CURRENT
Layout::AutoTextDefinition::TYPE_DATE_CREATED
Layout::AutoTextDefinition::TYPE_DATE_MODIFIED
Layout::AutoTextDefinition::TYPE_DATE_PUBLISHED

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
auto_texts = doc.auto_text_definitions
auto_texts.remove(auto_texts[10], true)

Overloads:

  • #remove(definition, convert_tags_to_text = true) ⇒ Object

    Parameters:

  • #remove(name, convert_tags_to_text = true) ⇒ Object

    Parameters:

  • #remove(index, convert_tags_to_text = true) ⇒ Object

    Parameters:

Raises:

  • (ArgumentError)

    if the definition that is being removed is mandatory

Version:

  • LayOut 2018