Class: Deba::Document
- Inherits:
-
Object
- Object
- Deba::Document
- Defined in:
- lib/deba/document.rb
Constant Summary collapse
- BLOCKQUOTE =
"> "
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #<<(segment) ⇒ Object
- #block_content ⇒ Object
- #break(*args) ⇒ Object
- #finish ⇒ Object
-
#initialize(extractor) ⇒ Document
constructor
A new instance of Document.
- #present? ⇒ Boolean
- #start(*args) ⇒ Object
Constructor Details
#initialize(extractor) ⇒ Document
Returns a new instance of Document.
6 7 8 9 10 11 |
# File 'lib/deba/document.rb', line 6 def initialize(extractor) @extractor = extractor @content = "" start end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/deba/document.rb', line 4 def content @content end |
Instance Method Details
#<<(segment) ⇒ Object
13 14 15 |
# File 'lib/deba/document.rb', line 13 def <<(segment) @segments << segment end |
#block_content ⇒ Object
38 39 40 41 42 |
# File 'lib/deba/document.rb', line 38 def block_content block_type = @args.shift @args.unshift(@segments) Deba::Stringifier.new(block_type.new(*@args).to_a).stringify end |
#break(*args) ⇒ Object
17 18 19 20 |
# File 'lib/deba/document.rb', line 17 def break(*args) finish start(*args) end |
#finish ⇒ Object
22 23 24 25 26 27 |
# File 'lib/deba/document.rb', line 22 def finish return unless present? @content << BLOCKQUOTE if @extractor.in_blockquote? @content << block_content end |
#present? ⇒ Boolean
34 35 36 |
# File 'lib/deba/document.rb', line 34 def present? @segments.any? { |segment| segment.is_a?(Deba::Span) && Deba::Utils.present?(segment.to_s) } end |
#start(*args) ⇒ Object
29 30 31 32 |
# File 'lib/deba/document.rb', line 29 def start(*args) @segments = [] @args = args end |