Class: Boilerpipe::Document::TextDocument
- Inherits:
-
Object
- Object
- Boilerpipe::Document::TextDocument
- Defined in:
- lib/boilerpipe/document/text_document.rb
Instance Attribute Summary collapse
-
#text_blocks ⇒ Object
readonly
Returns the value of attribute text_blocks.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #content ⇒ Object
- #debug_s ⇒ Object (also: #debug_string)
-
#initialize(title, text_blocks) ⇒ TextDocument
constructor
A new instance of TextDocument.
- #replace_text_blocks!(new_blocks) ⇒ Object
- #text(include_content, include_noncontent) ⇒ Object
Constructor Details
#initialize(title, text_blocks) ⇒ TextDocument
Returns a new instance of TextDocument.
7 8 9 10 |
# File 'lib/boilerpipe/document/text_document.rb', line 7 def initialize(title, text_blocks) @text_blocks = text_blocks @title = title end |
Instance Attribute Details
#text_blocks ⇒ Object (readonly)
Returns the value of attribute text_blocks.
4 5 6 |
# File 'lib/boilerpipe/document/text_document.rb', line 4 def text_blocks @text_blocks end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/boilerpipe/document/text_document.rb', line 5 def title @title end |
Instance Method Details
#content ⇒ Object
12 13 14 |
# File 'lib/boilerpipe/document/text_document.rb', line 12 def content text(true, false) end |
#debug_s ⇒ Object Also known as: debug_string
37 38 39 |
# File 'lib/boilerpipe/document/text_document.rb', line 37 def debug_s @text_blocks.map(&:to_s).join("\n") end |
#replace_text_blocks!(new_blocks) ⇒ Object
33 34 35 |
# File 'lib/boilerpipe/document/text_document.rb', line 33 def replace_text_blocks!(new_blocks) @text_blocks = new_blocks end |
#text(include_content, include_noncontent) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/boilerpipe/document/text_document.rb', line 16 def text(include_content, include_noncontent) s = '' @text_blocks.each do |text_block| case text_block.is_content? when true next unless include_content when false next unless include_noncontent end s << text_block.text s << "\n" end s end |