lib/rtf/node.rb
def to_rtf
         text = StringIO.new

         text << "{#{prefix}\\#{@character_set.id2name}"
         text << "\\deff#{@default_font}"
         text << "\\deflang#{@language}" if !@language.nil?
         text << "\\plain\\fs24\\fet1"
         text << "\n#{@fonts.to_rtf}"
         text << "\n#{@colours.to_rtf}" if @colours.size > 0
         text << "\n#{@information.to_rtf}"
         text << "\n#{@lists.to_rtf}"
         if @headers.compact != []
            text << "\n#{@headers[3].to_rtf}" if !@headers[3].nil?
            text << "\n#{@headers[2].to_rtf}" if !@headers[2].nil?
            text << "\n#{@headers[1].to_rtf}" if !@headers[1].nil?
            if @headers[1].nil? or @headers[2].nil?
               text << "\n#{@headers[0].to_rtf}"
            end
         end
         if @footers.compact != []
            text << "\n#{@footers[3].to_rtf}" if !@footers[3].nil?
            text << "\n#{@footers[2].to_rtf}" if !@footers[2].nil?
            text << "\n#{@footers[1].to_rtf}" if !@footers[1].nil?
            if @footers[1].nil? or @footers[2].nil?
               text << "\n#{@footers[0].to_rtf}"
            end
         end
         text << "\n#{@style.prefix(self)}" if !@style.nil?
         self.each {|entry| text << "\n#{entry.to_rtf}"}
         text << "\n}"

         text.string
      end
def to_rtf
         text = StringIO.new

         text << "{#{prefix}\\#{@character_set.id2name}"
         text << "\\deff#{@default_font}"
         text << "\\deflang#{@language}" if !@language.nil?
         text << "\\plain\\fs24\\fet1"
         text << "\n#{@fonts.to_rtf}"
         text << "\n#{@colours.to_rtf}" if @colours.size > 0
         text << "\n#{@information.to_rtf}"
         text << "\n#{@lists.to_rtf}"
         if @headers.compact != []
            text << "\n#{@headers[3].to_rtf}" if !@headers[3].nil?
            text << "\n#{@headers[2].to_rtf}" if !@headers[2].nil?
            text << "\n#{@headers[1].to_rtf}" if !@headers[1].nil?
            if @headers[1].nil? or @headers[2].nil?
               text << "\n#{@headers[0].to_rtf}"
            end
         end
         if @footers.compact != []
            text << "\n#{@footers[3].to_rtf}" if !@footers[3].nil?
            text << "\n#{@footers[2].to_rtf}" if !@footers[2].nil?
            text << "\n#{@footers[1].to_rtf}" if !@footers[1].nil?
            if @footers[1].nil? or @footers[2].nil?
               text << "\n#{@footers[0].to_rtf}"
            end
         end
         text << "\n#{@style.prefix(self)}" if !@style.nil?
         self.each {|entry| text << "\n#{entry.to_rtf}"}
         text << "\n}"

         text.string
      end
def to_rtf text = StringIO . new text << "{#{prefix}\\#{@character_set.id2name}" text << "\\deff#{@default_font}" text << "\\deflang#{@language}" if ! @language . nil? text << "\\plain\\fs24\\fet1" text << "\n#{@fonts.to_rtf}" text << "\n#{@colours.to_rtf}" if @colours . size > 0 text << "\n#{@information.to_rtf}" text << "\n#{@lists.to_rtf}" if @headers . compact != [ ] text << "\n#{@headers[3].to_rtf}" if ! @headers [ 3 ] . nil? text << "\n#{@headers[2].to_rtf}" if ! @headers [ 2 ] . nil? text << "\n#{@headers[1].to_rtf}" if ! @headers [ 1 ] . nil? if @headers [ 1 ] . nil? or @headers [ 2 ] . nil? text << "\n#{@headers[0].to_rtf}" end end if @footers . compact != [ ] text << "\n#{@footers[3].to_rtf}" if ! @footers [ 3 ] . nil? text << "\n#{@footers[2].to_rtf}" if ! @footers [ 2 ] . nil? text << "\n#{@footers[1].to_rtf}" if ! @footers [ 1 ] . nil? if @footers [ 1 ] . nil? or @footers [ 2 ] . nil? text << "\n#{@footers[0].to_rtf}" end end text << "\n#{@style.prefix(self)}" if ! @style . nil? self . each { | entry | text << "\n#{entry.to_rtf}" } text << "\n}" text . string end
This method generates the RTF text for a Document object.
This method generates the RTF text for a Document object .