Class: Gutenug::Paragraph
- Inherits:
-
Object
- Object
- Gutenug::Paragraph
- Defined in:
- lib/gutenug/paragraph.rb
Instance Method Summary collapse
-
#initialize(blob) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #invalid! ⇒ Object
- #invalid? ⇒ Boolean
- #sentences ⇒ Object
- #status ⇒ Object
- #suspect? ⇒ Boolean
- #to_s ⇒ Object
- #valid! ⇒ Object
Constructor Details
#initialize(blob) ⇒ Paragraph
Returns a new instance of Paragraph.
3 4 5 6 7 |
# File 'lib/gutenug/paragraph.rb', line 3 def initialize(blob) segmenter = PragmaticSegmenter::Segmenter.new(text: blob.join(' ')) @sentences = segmenter.segment _validate end |
Instance Method Details
#invalid! ⇒ Object
21 22 23 |
# File 'lib/gutenug/paragraph.rb', line 21 def invalid! @invalid = true end |
#invalid? ⇒ Boolean
25 26 27 |
# File 'lib/gutenug/paragraph.rb', line 25 def invalid? @invalid end |
#sentences ⇒ Object
13 14 15 |
# File 'lib/gutenug/paragraph.rb', line 13 def sentences @sentences end |
#status ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/gutenug/paragraph.rb', line 33 def status if invalid? :invalid elsif suspect? :suspect else :valid end end |
#suspect? ⇒ Boolean
29 30 31 |
# File 'lib/gutenug/paragraph.rb', line 29 def suspect? @suspect end |
#to_s ⇒ Object
9 10 11 |
# File 'lib/gutenug/paragraph.rb', line 9 def to_s @sentences.join(" ") end |
#valid! ⇒ Object
17 18 19 |
# File 'lib/gutenug/paragraph.rb', line 17 def valid! @invalid = false end |