Module: Artofwar

Defined in:
lib/artofwar.rb,
lib/artofwar/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.passageObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/artofwar.rb', line 5

def self.passage
    text = File.read('artwar.1b.txt')
  chapters = []
  lined_text = []

  text = text.split('----------------------------------------------------------------------').shift
  text_array = text.split("\n\n")
  text_array.pop
  
  3.times do
    text_array.shift
  end

  text_array.each do |thing|
    if thing =~ /\d/
      line = "#{thing}"
      lined_text.push(line)
    else
      chap_titles = "Chapter #{thing}"
      chapters.push(chap_titles)
    end
  end

  # puts chapters
  @passage = lined_text.sample
  puts @passage
end