Class: RandomShakespeare::Lines

Inherits:
Object
  • Object
show all
Defined in:
lib/random_shakespeare/lines.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser = nil) ⇒ Lines

Returns a new instance of Lines.



5
6
7
8
# File 'lib/random_shakespeare/lines.rb', line 5

def initialize(parser = nil)
  @parser = parser || Parser.new(Downloader::FILENAME)
  load_lines!
end

Instance Method Details

#nextObject



10
11
12
13
# File 'lib/random_shakespeare/lines.rb', line 10

def next
  load_lines! if lines_empty?
  random_line
end