Class: Deba::Document
- Inherits:
-
Object
- Object
- Deba::Document
- Defined in:
- lib/deba/document.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #<<(segment) ⇒ 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.
4 5 6 7 8 9 |
# File 'lib/deba/document.rb', line 4 def initialize(extractor) @extractor = extractor @content = "" start end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
2 3 4 |
# File 'lib/deba/document.rb', line 2 def content @content end |
Instance Method Details
#<<(segment) ⇒ Object
11 12 13 |
# File 'lib/deba/document.rb', line 11 def <<(segment) @segments << segment end |
#break(*args) ⇒ Object
15 16 17 18 |
# File 'lib/deba/document.rb', line 15 def break(*args) finish start(*args) end |
#finish ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/deba/document.rb', line 20 def finish return unless present? @args.unshift(@segments) block = @block_type.new(*@args).to_a block.unshift("> ") if @extractor.in_blockquote? @content << Deba::Stringifier.new(block).stringify end |
#present? ⇒ Boolean
36 37 38 |
# File 'lib/deba/document.rb', line 36 def present? @segments.any? { |segment| segment.is_a?(Deba::Span) && Deba::Utils.present?(segment.to_s) } end |
#start(*args) ⇒ Object
30 31 32 33 34 |
# File 'lib/deba/document.rb', line 30 def start(*args) @segments = [] @block_type = args.shift @args = args end |