Class: Ramesh::Client
- Inherits:
-
Object
- Object
- Ramesh::Client
- Defined in:
- lib/ramesh/client.rb
Constant Summary collapse
- MESHES_INDEX_URL =
"http://tokyo-ame.jwa.or.jp/scripts/mesh_index.js"
Instance Method Summary collapse
- #download_image(save_dir, minute = 0) ⇒ Object
- #download_sequential_images(save_dir, from, to) ⇒ Object
-
#initialize(logger) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(logger) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/ramesh/client.rb', line 5 def initialize(logger) @logger = logger end |
Instance Method Details
#download_image(save_dir, minute = 0) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ramesh/client.rb', line 9 def download_image(save_dir, minute = 0) unless valid_minutes?(minute) raise ArgumentError, "minutes must be a number; 0, 5, 10, ... 120" end image_name = name_from_minute(minute) image = Image.new(image_name, background_image, mask_image) image.save(save_dir, image_name) @logger.info("Downloaded: #{image_name}.jpg") end |
#download_sequential_images(save_dir, from, to) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ramesh/client.rb', line 21 def download_sequential_images(save_dir, from, to) unless valid_minutes?(from) && valid_minutes?(to) raise ArgumentError, "minutes must be a number; 0, 5, 10, ... 120" end (from..to).step(5) do |minute| download_image(save_dir, minute) end end |