Sha256: f83c8aec149433b6bba89ca1a9e3964cb02b41d7838c013197a200ee9642f004

Contents?: true

Size: 931 Bytes

Versions: 4

Compression:

Stored size: 931 Bytes

Contents

module Boilerpipe
  module Document
    class TextDocument
      attr_reader :text_blocks
      attr_accessor :title

      def initialize(title, text_blocks)
        @text_blocks = text_blocks
        @title = title
      end

      def content
        text(true, false)
      end

      def text(include_content, include_noncontent)
        s = ''
        @text_blocks.each do |text_block|
          case text_block.is_content?
          when true
            next unless include_content
            s << text_block.text
            s << "\n"
          when false
            next unless include_noncontent
           s << text_block.text
           s << "\n"
          end
        end
        s
      end

      def replace_text_blocks!(new_blocks)
        @text_blocks = new_blocks
      end

      def debug_s
        @text_blocks.map(&:to_s).join("\n")
      end
      alias_method :debug_string, :debug_s

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
boilerpipe-ruby-0.4.0 lib/boilerpipe/document/text_document.rb
boilerpipe-ruby-0.3.0 lib/boilerpipe/document/text_document.rb
boilerpipe-ruby-0.2.0 lib/boilerpipe/document/text_document.rb
boilerpipe-ruby-0.1.1 lib/boilerpipe/document/text_document.rb