Skip to content

Instantly share code, notes, and snippets.

@yoshinari-nomura
Last active June 27, 2018 08:15
Show Gist options
  • Select an option

  • Save yoshinari-nomura/335481fa28a7aa84468f79e5906953e6 to your computer and use it in GitHub Desktop.

Select an option

Save yoshinari-nomura/335481fa28a7aa84468f79e5906953e6 to your computer and use it in GitHub Desktop.
dummy event emitter
#!/usr/bin/env ruby
require "./event.rb"
TODAYS_EVENTS_SAMPLE = [
"allday だれかさん誕生日 おめでとう",
"10:00-12:00 GN検討打合せ",
"11:30-12:30 昼食会",
"13:00-16:00 New開発",
"17:15-18:00 テスト",
"18:30-20:30 New開発打上 きしもと食堂でやります"
]
events = EventCollection.new
TODAYS_EVENTS_SAMPLE.each do |line|
time_range, summary, description = line.split
today = Date.today
zone = DateTime.now.zone
if time_range == "allday"
start_time, end_time = today, today
else
start_time = DateTime.parse(time_range.split('-').first + zone)
end_time = DateTime.parse(time_range.split('-').last + zone)
end
events << Event.new(start_time, end_time, summary, description)
end
json = events.to_json
while true
puts json
STDOUT.flush
sleep 3
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment