Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/markov-reloaded.rb

Instance Method Summary collapse

Instance Method Details

#spaceNewLinesObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/markov-reloaded.rb', line 3

def spaceNewLines
  out = ""
  for i in self
    if i == "\n"
      out += " "
      out += "\n"
    else
      out += i
    end
  end
  out
end

#toMarkovArray(separator, terminator) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/markov-reloaded.rb', line 16

def toMarkovArray(separator, terminator)
  arr = self.dup
  arr += separator if self[self.length-1] != separator
  arr = arr.lines(separator)
  arr = arr.map do |e| e.chop end
  array = []
  for i in arr
    if i[i.length-1] == terminator
      array.push(i.chop)
      array.push(terminator)
    else
      array.push i
    end
  end
  array
end