Class: RRTF::GeometryNode
- Inherits:
-
CommandNode
- Object
- Node
- ContainerNode
- CommandNode
- RRTF::GeometryNode
- Defined in:
- lib/rrtf/node/geometry_node.rb
Overview
This class represents a geometry object (shape or text box) within an RTF document.
Instance Attribute Summary collapse
- #properties ⇒ Object readonly
Attributes inherited from CommandNode
#prefix, #split, #suffix, #wrap
Attributes inherited from ContainerNode
Attributes inherited from Node
Instance Method Summary collapse
-
#<<(text) ⇒ Object
Overrides the CommandNode#<< method to prevent text from being added to geometry objects directly.
-
#geometry(properties = nil) ⇒ Object
Overrides the CommandNode#geometry method to prevent geometry objects from being nested in other geometry objects.
-
#initialize(parent, properties = nil) ⇒ GeometryNode
constructor
Constructor for the GeometryNode class.
- #to_rtf ⇒ Object
Methods inherited from CommandNode
#apply, #column_break, #footnote, #image, #line_break, #link, #list, #paragraph, #section, #tab, #table
Methods inherited from ContainerNode
#[], #each, #first, #last, #size, #store
Methods inherited from Node
#is_root?, #next_node, #previous_node, #root
Constructor Details
#initialize(parent, properties = nil) ⇒ GeometryNode
Constructor for the GeometryNode class.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rrtf/node/geometry_node.rb', line 14 def initialize(parent, properties = nil) case properties when Hash @properties = GeometryProperties.new(properties) when GeometryProperties @properties = properties else RTFError.fire("Invalid geometry properties '#{properties}'.") end unless properties.nil? prefix = '{\shp{\*\shpinst' prefix << @properties.to_rtf unless properties.nil? super(parent, prefix, '}}', false, false) end |
Instance Attribute Details
#properties ⇒ Object (readonly)
8 9 10 |
# File 'lib/rrtf/node/geometry_node.rb', line 8 def properties @properties end |
Instance Method Details
#<<(text) ⇒ Object
Overrides the CommandNode#<< method to prevent text from being added to geometry objects directly. Calls CommandNode#paragraph instead.
61 62 63 |
# File 'lib/rrtf/node/geometry_node.rb', line 61 def <<(text) self.paragraph << text end |
#geometry(properties = nil) ⇒ Object
Overrides the CommandNode#geometry method to prevent geometry objects from being nested in other geometry objects.
53 54 55 |
# File 'lib/rrtf/node/geometry_node.rb', line 53 def geometry(properties = nil) RTFError.fire("Cannot place a geometry object inside of another.") end |
#to_rtf ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rrtf/node/geometry_node.rb', line 30 def to_rtf text = StringIO.new text << @prefix unless self.size() == 0 text << '{\shptxt' self.each do |entry| text << "\n" text << entry.to_rtf end # each text << '}' end # unless text << @suffix text.string end |