Class: Gutenug::Paragraph

Inherits:
Object
  • Object
show all
Defined in:
lib/gutenug/paragraph.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/gutenug/paragraph.rb', line 25

def invalid?
  @invalid
end

#sentencesObject



13
14
15
# File 'lib/gutenug/paragraph.rb', line 13

def sentences
  @sentences
end

#statusObject



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

Returns:

  • (Boolean)


29
30
31
# File 'lib/gutenug/paragraph.rb', line 29

def suspect?
  @suspect
end

#to_sObject



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