Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment