Skip to content

Instantly share code, notes, and snippets.

@hiroto3432
Created June 16, 2018 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroto3432/2564d5b69bcffe5382c2ccd75d0bb0e9 to your computer and use it in GitHub Desktop.
Save hiroto3432/2564d5b69bcffe5382c2ccd75d0bb0e9 to your computer and use it in GitHub Desktop.
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