Created
June 16, 2018 09:37
-
-
Save hiroto3432/2564d5b69bcffe5382c2ccd75d0bb0e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require "date" | |
require 'ruby_gntp' | |
data = CSV.read("TimeTable.csv") | |
data.map! { |item| [item[0].to_i,item[1..item.length].map! { |i| i.to_i } ] } | |
table = Hash[*data.flatten(1)] | |
dn = DateTime.now | |
n_hour = dn.hour.to_i | |
n_min = dn.min.to_i | |
t_hour = n_min <= 40 ? n_hour : (n_hour + 1)%24 | |
t_min = n_min <= 40 ? n_min+20 : n_min-40 | |
if table[t_hour].index(t_min) != nil then | |
GNTP.notify( | |
:app_name => "NoticeTrain", | |
:title => "20分前通知", | |
:text => t_hour.to_s+"時"+t_min.to_s+"分の電車まであと20分です", | |
:icon => "", | |
:sticky=> false, | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment