Class RTF::CommandNode
In: lib/rtf/node.rb
Parent: ContainerNode

This class represents a RTF command element within a document. This class is concrete enough to be used on its own but will also be used as the base class for some specific command node types.

Methods

<<   apply   background   bold   color   colour   font   footnote   foreground   image   italic   line_break   new   paragraph   superscript   table   to_rtf   underline   write  

External Aliases

split -> split?

Attributes

prefix  [R]  Attribute accessor.
prefix  [W]  Attribute mutator.
split  [R]  Attribute accessor.
split  [W]  Attribute mutator.
suffix  [R]  Attribute accessor.
suffix  [W]  Attribute mutator.

Public Class methods

This is the constructor for the CommandNode class.

Parameters

parent:A reference to the node that owns the new node.
prefix:A String containing the prefix text for the command.
suffix:A String containing the suffix text for the command. Defaults to nil.
split:A boolean to indicate whether the prefix and suffix should be written to separate lines whether the node is converted to RTF. Defaults to true.

Public Instance methods

This method adds text to a command node. If the last child node of the target node is a TextNode then the text is appended to that. Otherwise a new TextNode is created and append to the node.

Parameters

text:The String of text to be written to the node.

This method provides a short cut means for applying multiple styles via single command node. The method accepts a block that will be passed a reference to the node created. Once the block is complete the new node will be append as the last child of the CommandNode the method is called on.

Parameters

style:A reference to a CharacterStyle object that contains the style settings to be applied.

Exceptions

RTFError:Generated whenever a non-character style is specified to the method.

This method provides a short cut means of creating a background colour command node. The method accepts a block that will be passed a single parameter which will be a reference to the background colour node created. After the block is complete the background colour node is appended to the end of the child nodes on the object that the method is called against.

Parameters

colour:The background colour to be applied by the command.

This method provides a short cut means of creating a bold command node. The method accepts a block that will be passed a single parameter which will be a reference to the bold node created. After the block is complete the bold node is appended to the end of the child nodes on the object that the method is call against.

color(fore, back)

Alias for colour

This method provides a short cut menas of creating a colour node that deals with foreground and background colours. The method accepts a block that will be passed a single parameter which will be a reference to the colour node created. After the block is complete the colour node is append to the end of the child nodes on the object that the method is called against.

Parameters

fore:The foreground colour to be applied by the command.
back:The background colour to be applied by the command.

This method provides a short cut means of creating a font command node. The method accepts a block that will be passed a single parameter which will be a reference to the font node created. After the block is complete the font node is appended to the end of the child nodes on the object that the method is called against.

Parameters

font:A reference to font object that represents the font to be used within the node.
size:An integer size setting for the font. Defaults to nil to indicate that the current font size should be used.

This method inserts a footnote at the current position in a node.

Parameters

text:A string containing the text for the footnote.

This method provides a short cut means of creating a foreground colour command node. The method accepts a block that will be passed a single parameter which will be a reference to the foreground colour node created. After the block is complete the foreground colour node is appended to the end of the child nodes on the object that the method is called against.

Parameters

colour:The foreground colour to be applied by the command.

This method inserts a new image at the current position in a node.

Parameters

source:Either a string containing the path and name of a file or a File object for the image file to be inserted.

Exceptions

RTFError:Generated whenever an invalid or inaccessible file is specified or the image file type is not supported.

This method provides a short cut means of creating an italic command node. The method accepts a block that will be passed a single parameter which will be a reference to the italic node created. After the block is complete the italic node is appended to the end of the child nodes on the object that the method is call against.

This method provides a short cut means of creating a line break command node. This command node does not take a block and may possess no other content.

This method provides a short cut means of creating a paragraph command node. The method accepts a block that will be passed a single parameter which will be a reference to the paragraph node created. After the block is complete the paragraph node is appended to the end of the child nodes on the object that the method is called against.

Parameters

style:A reference to a ParagraphStyle object that defines the style for the new paragraph. Defaults to nil to indicate that the currently applied paragraph styling should be used.

This method provides a short cut means of creating a superscript command node. The method accepts a block that will be passed a single parameter which will be a reference to the superscript node created. After the block is complete the superscript node is appended to the end of the child nodes on the object that the method is call against.

This method creates a new table node and returns it. The method accepts a block that will be passed the table as a parameter. The node is added to the node the method is called upon after the block is complete.

Parameters

rows:The number of rows that the table contains.
columns:The number of columns that the table contains.
*widths:One or more integers representing the widths for the table columns.

This method generates the RTF text for a CommandNode object.

This method provides a short cut means of creating an underline command node. The method accepts a block that will be passed a single parameter which will be a reference to the underline node created. After the block is complete the underline node is appended to the end of the child nodes on the object that the method is call against.

write(text)

Alias for #<<

[Validate]