class Sentencemate::Sentence

Object used to emulate a sentence in text.

Public Class Methods

new(statement) click to toggle source
# File lib/Sentencemate.rb, line 25
def initialize(statement)
  @sentence = statement
  statement = statement.chop
  statement = statement.downcase
  lst = statement.split(" ")
  @words = []
  for elem in lst
    @words << Word.new(elem)
  end
  if @sentence[@sentence.length-1] == "?"
    @question = true
  else
    @question = false
  end
end

Public Instance Methods

[](i) click to toggle source
# File lib/Sentencemate.rb, line 49
def [](i)
  @words[i].get()
end
addpunc(symbol) click to toggle source
# File lib/Sentencemate.rb, line 55
def addpunc(symbol)
  @words[self.length-1].setword(@words[self.length-1].get << symbol)
end
addword(str) click to toggle source
# File lib/Sentencemate.rb, line 40
def addword(str)
  @words << Word.new(str)
end
addword_to_place(str, i) click to toggle source
# File lib/Sentencemate.rb, line 43
def addword_to_place(str, i)
  @words.insert(i, Word.new(str))
end
checkforword(str) click to toggle source
# File lib/Sentencemate.rb, line 58
def checkforword(str)
  for elem in @words
    if elem.get == str
      return true
    end
  end
  return false
end
length() click to toggle source
# File lib/Sentencemate.rb, line 52
def length
  @words.length
end
set_word(i, other) click to toggle source
# File lib/Sentencemate.rb, line 46
def set_word(i, other)
  @words[i].setword(other)
end