class Sentencemate::Paragraph

object meant to simulate a paragraph or block of text.

Public Class Methods

new(text) click to toggle source
# File lib/Sentencemate.rb, line 69
def initialize(text)
  @paragraph = text
  @sentence_box = []
  count = 0
  until text.length == 0 do
    if text[count] == "."
      @sentence_box << Sentence.new(text[0..count])
      text = self.cutstring(text, 0, count)
      count = 0
    elsif text[count] == "?"
      @sentence_box << Sentence.new(text[0..count])
      text = self.cutstring(text, 0, count)
      count = 0
    elsif text[count] == "!"
      @sentence_box << Sentence.new(text[0..count])
      text = self.cutstring(text, 0, count)
      count = 0
    else
      count += 1
    end
  end
end

Public Instance Methods

[](i) click to toggle source
# File lib/Sentencemate.rb, line 95
def [](i)
  @sentence_box[i]
end
checkforword(str) click to toggle source
# File lib/Sentencemate.rb, line 107
def checkforword(str)
  for sentence in @sentence_box
    if sentence.checkforword(str)
      return true
    end
  end
  return false
end
cutstring(str, start, stop) click to toggle source
# File lib/Sentencemate.rb, line 91
def cutstring(str, start, stop)
  str[start..stop] = ""
  return str
end
lettercount() click to toggle source
# File lib/Sentencemate.rb, line 101
def lettercount
  return @paragraph.split("").length
end
paragraph() click to toggle source
# File lib/Sentencemate.rb, line 98
def paragraph
  return @paragraph
end
word_at_index(i) click to toggle source
# File lib/Sentencemate.rb, line 115
def word_at_index(i)
  return @paragraph.split(" ")[i]
end
wordcount() click to toggle source
# File lib/Sentencemate.rb, line 104
def wordcount
  return @paragraph.split(" ").length
end