Class: Downloader
- Inherits:
-
Object
- Object
- Downloader
- Defined in:
- lib/downloader.rb
Constant Summary collapse
- DOWNLOAD_PATH =
'https://acpmasquerade-nepal-loadshedding-schedule-by-sparrow-sms.p.mashape.com/schedule.php'
- API_KEY =
'8ibMI63bqPmshv9aq5XoZtwTDNxBp11nUMNjsnVVa3A88wMy1E'
- HEADER =
'X-Mashape-Key'
- INSTALL_PATH =
File.('~/.schedule.yml')
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#schedule_json ⇒ Object
readonly
Returns the value of attribute schedule_json.
Instance Method Summary collapse
-
#download ⇒ Object
Download the schedule form masquerade API.
-
#initialize(download_path = nil) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(download_path = nil) ⇒ Downloader
Returns a new instance of Downloader.
9 10 11 12 |
# File 'lib/downloader.rb', line 9 def initialize(download_path=nil) @path ||= download_path || DOWNLOAD_PATH @schedule_json = Hash.new end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/downloader.rb', line 7 def path @path end |
#schedule_json ⇒ Object (readonly)
Returns the value of attribute schedule_json.
7 8 9 |
# File 'lib/downloader.rb', line 7 def schedule_json @schedule_json end |
Instance Method Details
#download ⇒ Object
Download the schedule form masquerade API
15 16 17 18 19 20 21 |
# File 'lib/downloader.rb', line 15 def download puts "Downloading latest schedule".colorize(:green) (1..7).each do |group| group_schedule = download_for_group(group) @schedule_json.merge!({group => group_schedule}) end end |