Class: RandomShakespeare::Downloader

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

Constant Summary collapse

URL =
'http://www.ibiblio.org/xml/examples/shakespeare/macbeth.xml'
FILENAME =
'lib/random_shakespeare/data/macbeth.xml'

Instance Method Summary collapse

Constructor Details

#initialize(filename = nil) ⇒ Downloader

Returns a new instance of Downloader.



8
9
10
# File 'lib/random_shakespeare/downloader.rb', line 8

def initialize(filename = nil)
  @filename = filename || FILENAME
end

Instance Method Details

#fileObject



12
13
14
15
# File 'lib/random_shakespeare/downloader.rb', line 12

def file
  download unless File.exist? @filename
  open_file
end