Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 31 lines (23 sloc) 0.683 kB
da7b8b5 @floere + instance eval in-state-transition block
authored
1 # If using the gem, replace with:
2 #
3 # require 'rubygems'
4 # require 'james'
5 require File.expand_path '../../lib/james', __FILE__
6
7 require 'rubygems'
8 require 'barometer'
9
73a8e97 @floere + Renamed to use American spelling – James is slightly irked, but agr…
authored
10 # Weather dialog by Florian Hanke.
da7b8b5 @floere + instance eval in-state-transition block
authored
11 #
12 # This is a very simple James example.
13 #
73a8e97 @floere + Renamed to use American spelling – James is slightly irked, but agr…
authored
14 class WeatherDialog
da7b8b5 @floere + instance eval in-state-transition block
authored
15
73a8e97 @floere + Renamed to use American spelling – James is slightly irked, but agr…
authored
16 include James::Dialog
da7b8b5 @floere + instance eval in-state-transition block
authored
17
73a8e97 @floere + Renamed to use American spelling – James is slightly irked, but agr…
authored
18 def initialize location
da7b8b5 @floere + instance eval in-state-transition block
authored
19 Barometer.config = { 1 => [:yahoo, :google], 2 => :wunderground }
20
73a8e97 @floere + Renamed to use American spelling – James is slightly irked, but agr…
authored
21 @barometer = Barometer.new location
da7b8b5 @floere + instance eval in-state-transition block
authored
22 end
23
24 hear 'How is the weather?' => :weather
25 state :weather do
26 hear ['How warm is it?', 'How cold is it?'] => ->(){ "It is #{@barometer.measure.current.temperature.celsius} degrees celsius" }
27 end
28
29 end
30
39b4078 @floere + 0.1.0
authored
31 James.use WeatherDialog.new('Melbourne')
Something went wrong with that request. Please try again.