Class: GMS::Downloader
- Inherits:
-
Object
- Object
- GMS::Downloader
- Defined in:
- lib/google-map-stitch/downloader.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
Instance Method Summary collapse
-
#initialize(files, output_dir = "tiles") ⇒ Downloader
constructor
A new instance of Downloader.
- #mkdir?(dir) ⇒ Boolean
- #process ⇒ Object
Constructor Details
#initialize(files, output_dir = "tiles") ⇒ Downloader
Returns a new instance of Downloader.
8 9 10 11 |
# File 'lib/google-map-stitch/downloader.rb', line 8 def initialize(files, output_dir="tiles") @output_dir = output_dir @files = files end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
6 7 8 |
# File 'lib/google-map-stitch/downloader.rb', line 6 def files @files end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
6 7 8 |
# File 'lib/google-map-stitch/downloader.rb', line 6 def output_dir @output_dir end |
Instance Method Details
#mkdir?(dir) ⇒ Boolean
13 14 15 |
# File 'lib/google-map-stitch/downloader.rb', line 13 def mkdir?(dir) Dir.mkdir(dir) if !Dir.exists?(dir) end |
#process ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/google-map-stitch/downloader.rb', line 17 def process mkdir?(@output_dir) @files.each do |tile| mkdir?(File.join(@output_dir,tile[:dir])) File.open(File.join(@output_dir,tile[:dir],tile[:file]), 'w+') do |file| open(tile[:url], 'rb') do |image| file.write(image.read) end end end end |