Sha256: f8dbc4521d1f502e5473240f85b1e2b2fd4edd7ba096ea8406b863c3a7b6c94a
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
module RRTF # This class represents a geometry object (shape or text box) within an RTF # document. # @author Wesley Hileman # @since 1.0.0 class GeometryNode < CommandNode attr_reader :properties # Constructor for the GeometryNode class. # # @param [Hash, GeometryProperties] properties a hash or GeometryProperties # object specifying the properties of the geometry object. 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 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 # Overrides the {CommandNode#geometry} method to prevent geometry objects # from being nested in other geometry objects. # # @raise [RTFError] whenever called. def geometry(properties = nil) RTFError.fire("Cannot place a geometry object inside of another.") end # Overrides the {CommandNode#<<} method to prevent text from being added # to geometry objects directly. Calls {#paragraph} instead. # # @raise [RTFError] whenever called. def <<(text) self.paragraph << text end end # class GeometryNode end # module RRTF
Version data entries
6 entries across 6 versions & 1 rubygems