larynx 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -27,45 +27,45 @@ Simplest possible
27
27
 
28
28
  Using the bare Application class, below is a guessing game.
29
29
 
30
- class Guess < Larynx::Application
31
- def run
32
- @number = rand(9) + 1
33
- @guess = ''
34
- @guesses = 0
35
- get_guess
36
- end
37
-
38
- def get_guess
39
- if @guesses < 3
40
- speak(guess_prompt) { @guesses += 1 }
41
- else
42
- speak "Sorry you didn't guess it. It was #{@number}. Try again soon.", :bargein => false
43
- hangup
44
- end
45
- end
46
-
47
- def guess_prompt
48
- @guesses == 0 ? 'Guess a number between 1 and 9.' : 'Have another guess.'
30
+ class Guess < Larynx::Application
31
+ def run
32
+ @number = rand(9) + 1
33
+ @guess = ''
34
+ @guesses = 0
35
+ get_guess
36
+ end
37
+
38
+ def get_guess
39
+ if @guesses < 3
40
+ speak(guess_prompt) { @guesses += 1 }
41
+ else
42
+ speak "Sorry you didn't guess it. It was #{@number}. Try again soon.", :bargein => false
43
+ hangup
44
+ end
45
+ end
46
+
47
+ def guess_prompt
48
+ @guesses == 0 ? 'Guess a number between 1 and 9.' : 'Have another guess.'
49
+ end
50
+
51
+ def check_guess
52
+ if @guess.to_i == @number
53
+ speak "You got it! It was #{@guess}. It took you #{@guesses} guesses.", :bargein => false
54
+ speak "Thanks for playing."
55
+ hangup
56
+ else
57
+ speak "No it's not #{@guess}."
58
+ get_guess
59
+ end
60
+ end
61
+
62
+ def dtmf_received(input)
63
+ @guess = input
64
+ check_guess
65
+ end
49
66
  end
50
67
 
51
- def check_guess
52
- if @guess.to_i == @number
53
- speak "You got it! It was #{@guess}. It took you #{@guesses} guesses.", :bargein => false
54
- speak "Thanks for playing."
55
- hangup
56
- else
57
- speak "No it's not #{@guess}."
58
- get_guess
59
- end
60
- end
61
-
62
- def dtmf_received(input)
63
- @guess = input
64
- check_guess
65
- end
66
- end
67
-
68
- Larynx.answer {|call| Guess.run(call) }
68
+ Larynx.answer {|call| Guess.run(call) }
69
69
 
70
70
  A more sophisticated example using the Form class
71
71
 
data/lib/larynx/form.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Larynx
2
2
  class Form < Application
3
3
  include Fields
4
+ @@setup = nil
4
5
 
5
6
  def self.setup(&block)
6
7
  @@setup = block
@@ -1,3 +1,3 @@
1
1
  module Larynx
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Meehan