123456789_123456789_123456789_123456789_123456789_

Class: Layout::AutoTextDefinitions

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

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

Instance Method Details

The #[] method returns a value from the array of 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 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
Layout::AutoTextDefinition::TYPE_PAGE_COUNT
Layout::AutoTextDefinition::TYPE_SEQUENCE

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)

Raises:

  • (ArgumentError)

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

Version:

  • LayOut 2018

#each {|auto_text| ... }

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

Examples:

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

Version:

  • LayOut 2018

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

The #remove method removes an AutoTextDefinition from the Document.

The 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
Layout::AutoTextDefinition::TYPE_PAGE_COUNT
Layout::AutoTextDefinition::TYPE_SEQUENCE

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)

    Parameters:

  • #remove(name, convert_tags_to_text = true)

    Parameters:

  • #remove(index, convert_tags_to_text = true)

    Parameters:

    • index (Integer)

      The index of the AutoTextDefinition to remove

    • convert_tags_to_text (Boolean) (defaults to: true)

Raises:

  • (ArgumentError)

    if the definition that is being removed is mandatory

Version:

  • LayOut 2018

#size

Alias for #length.