Skip to content
Browse files

+ Reminder dialog example

  • Loading branch information...
1 parent c212c4f commit 2645ec2b680e81c822dfb3c89f06c63f94614d9e @floere committed
Showing with 31 additions and 0 deletions.
  1. +31 −0 examples/reminder_dialog.rb
View
31 examples/reminder_dialog.rb
@@ -0,0 +1,31 @@
+# If using the gem, replace with:
+#
+# require 'rubygems'
+# require 'james'
+require File.expand_path '../../lib/james', __FILE__
+
+# Simple reminder dialog by Florian Hanke.
+#
+James.dialog do
+
+ hear 'Set a reminder' => :reminder
+
+ state :reminder do
+ 10.downto(1).each do |i|
+ hear "Remind me in #{i} hours" => (->() do
+ # Run a thread that sleeps i hours.
+ #
+ Thread.new do
+ sleep i
+ James.controller.say "Hi, this is James, you set a reminder #{i} hours ago, so I am reminding you! "*3
+ end
+
+ # Return affirmative message.
+ #
+ "Ok, I'll remind you in #{i} hours."
+ end)
+ end
+ into { "In how many hours should I remind you?" }
+ end
+
+end

0 comments on commit 2645ec2

Please sign in to comment.
Something went wrong with that request. Please try again.