Skip to content
Browse files

+ correctly pluralize the hours in recognition and speech

  • Loading branch information...
1 parent 31ce3d1 commit 28e0dc580bce610c5b9dd55ab905cc4b703a0144 @floere committed Jun 28, 2011
Showing with 13 additions and 4 deletions.
  1. +13 −4 examples/reminder_dialog.rb
View
17 examples/reminder_dialog.rb
@@ -4,25 +4,34 @@
# require 'james'
require File.expand_path '../../lib/james', __FILE__
+module PluralizedHour
+ def pluralized_hour i
+ "#{i} hour#{ 's' if i > 1 }"
+ end
+end
+
# Simple reminder dialog by Florian Hanke.
#
James.dialog do
+ include PluralizedHour
hear 'Set a reminder' => :reminder
-
+
state :reminder do
+ extend PluralizedHour
+
10.downto(1).each do |i|
- hear "Remind me in #{i} hours" => (->() do
+ hear "Remind me in #{pluralized_hour(i)}" => (->() do
# Run a thread that sleeps i hours.
#
Thread.new do
sleep i*3600
- James.controller.say "Hi, this is James, you set a reminder #{i} hours ago, so I am reminding you! "*3
+ James.controller.say "Hi, this is James, you set a reminder #{pluralized_hour(i)} ago, so I am reminding you! "*3
end
# Return affirmative message.
#
- "Ok, I'll remind you in #{i} hours."
+ "Ok, I'll remind you in #{pluralized_hour(i)}."
end)
end
into { "In how many hours should I remind you?" }

0 comments on commit 28e0dc5

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