Class: RSpecRayo::Call
- Inherits:
-
Object
- Object
- RSpecRayo::Call
- Defined in:
- lib/rspec-rayo/rayo/call.rb
Instance Attribute Summary collapse
-
#call_id ⇒ Object
Returns the value of attribute call_id.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #accept ⇒ Object
- #answer ⇒ Object
- #ask(options = {}) ⇒ Object
- #call_event ⇒ Object
- #call_event=(other) ⇒ Object
- #conference(options = {}) ⇒ Object
- #dial(options = {}) ⇒ Object
- #dtmf(tones) ⇒ Object
- #hangup ⇒ Object
-
#initialize(options) ⇒ Call
constructor
A new instance of Call.
- #input(options = {}) ⇒ Object
- #join(options = {}) ⇒ Object
- #last_event?(timeout = 2) ⇒ Boolean
- #mute ⇒ Object
- #next_event(timeout = nil) ⇒ Object
- #output(options = {}) ⇒ Object
- #record(options = {}) ⇒ Object
- #redirect(options = {}) ⇒ Object
- #reject(reason = nil) ⇒ Object
- #ring_event ⇒ Object
- #ring_event=(other) ⇒ Object
- #say(options = {}) ⇒ Object
- #transfer(options = {}) ⇒ Object
- #unjoin(options = {}) ⇒ Object
- #unmute ⇒ Object
Constructor Details
#initialize(options) ⇒ Call
Returns a new instance of Call.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rspec-rayo/rayo/call.rb', line 8 def initialize() @call_event = FutureResource.new self.call_event = [:call_event] if [:call_event] @ring_event = FutureResource.new @protocol = [:protocol] @queue = [:queue] @read_timeout = [:read_timeout] || 5 @write_timeout = [:write_timeout] || 5 @status = :offered end |
Instance Attribute Details
#call_id ⇒ Object
Returns the value of attribute call_id.
5 6 7 |
# File 'lib/rspec-rayo/rayo/call.rb', line 5 def call_id @call_id end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/rspec-rayo/rayo/call.rb', line 6 def queue @queue end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/rspec-rayo/rayo/call.rb', line 5 def status @status end |
Instance Method Details
#accept ⇒ Object
19 20 21 22 23 |
# File 'lib/rspec-rayo/rayo/call.rb', line 19 def accept write(Punchblock::Command::Accept.new).tap do |response| @status = :accepted if response end end |
#answer ⇒ Object
25 26 27 |
# File 'lib/rspec-rayo/rayo/call.rb', line 25 def answer write Punchblock::Command::Answer.new end |
#ask(options = {}) ⇒ Object
29 30 31 |
# File 'lib/rspec-rayo/rayo/call.rb', line 29 def ask( = {}) write Punchblock::Component::Tropo::Ask.new() end |
#call_event ⇒ Object
109 110 111 |
# File 'lib/rspec-rayo/rayo/call.rb', line 109 def call_event @call_event.resource @write_timeout end |
#call_event=(other) ⇒ Object
113 114 115 116 117 |
# File 'lib/rspec-rayo/rayo/call.rb', line 113 def call_event=(other) raise ArgumentError, 'Call event must be a Punchblock::Event::Offer' unless other.is_a? Punchblock::Event::Offer @call_event.resource = other @call_id = other.call_id end |
#conference(options = {}) ⇒ Object
33 34 35 |
# File 'lib/rspec-rayo/rayo/call.rb', line 33 def conference( = {}) write Punchblock::Component::Tropo::Conference.new() end |
#dial(options = {}) ⇒ Object
37 38 39 |
# File 'lib/rspec-rayo/rayo/call.rb', line 37 def dial( = {}) write Punchblock::Command::Dial.new() end |
#dtmf(tones) ⇒ Object
93 94 95 |
# File 'lib/rspec-rayo/rayo/call.rb', line 93 def dtmf(tones) write Punchblock::Command::DTMF.new(:tones => tones) end |
#hangup ⇒ Object
41 42 43 44 45 |
# File 'lib/rspec-rayo/rayo/call.rb', line 41 def hangup write(Punchblock::Command::Hangup.new).tap do |response| @status = :finished if response end end |
#input(options = {}) ⇒ Object
73 74 75 |
# File 'lib/rspec-rayo/rayo/call.rb', line 73 def input( = {}) write Punchblock::Component::Input.new() end |
#join(options = {}) ⇒ Object
77 78 79 |
# File 'lib/rspec-rayo/rayo/call.rb', line 77 def join( = {}) write Punchblock::Command::Join.new() end |
#last_event?(timeout = 2) ⇒ Boolean
97 98 99 100 101 102 103 |
# File 'lib/rspec-rayo/rayo/call.rb', line 97 def last_event?(timeout = 2) begin next_event timeout rescue Timeout::Error true end end |
#mute ⇒ Object
85 86 87 |
# File 'lib/rspec-rayo/rayo/call.rb', line 85 def mute write Punchblock::Command::Mute.new end |
#next_event(timeout = nil) ⇒ Object
105 106 107 |
# File 'lib/rspec-rayo/rayo/call.rb', line 105 def next_event(timeout = nil) Timeout::timeout(timeout || @read_timeout) { @queue.pop } end |
#output(options = {}) ⇒ Object
69 70 71 |
# File 'lib/rspec-rayo/rayo/call.rb', line 69 def output( = {}) write Punchblock::Component::Output.new() end |
#record(options = {}) ⇒ Object
65 66 67 |
# File 'lib/rspec-rayo/rayo/call.rb', line 65 def record( = {}) write Punchblock::Component::Record.new() end |
#redirect(options = {}) ⇒ Object
47 48 49 |
# File 'lib/rspec-rayo/rayo/call.rb', line 47 def redirect( = {}) write Punchblock::Command::Redirect.new() end |
#reject(reason = nil) ⇒ Object
51 52 53 54 55 |
# File 'lib/rspec-rayo/rayo/call.rb', line 51 def reject(reason = nil) write(Punchblock::Command::Reject.new(reason)).tap do |response| @status = :finished if response end end |
#ring_event ⇒ Object
119 120 121 |
# File 'lib/rspec-rayo/rayo/call.rb', line 119 def ring_event @ring_event.resource @write_timeout end |
#ring_event=(other) ⇒ Object
123 124 125 126 |
# File 'lib/rspec-rayo/rayo/call.rb', line 123 def ring_event=(other) raise ArgumentError, 'Ring event must be a Punchblock::Event::Ringing' unless other.is_a? Punchblock::Event::Ringing @ring_event.resource = other end |
#say(options = {}) ⇒ Object
57 58 59 |
# File 'lib/rspec-rayo/rayo/call.rb', line 57 def say( = {}) write Punchblock::Component::Tropo::Say.new() end |
#transfer(options = {}) ⇒ Object
61 62 63 |
# File 'lib/rspec-rayo/rayo/call.rb', line 61 def transfer( = {}) write Punchblock::Component::Tropo::Transfer.new() end |
#unjoin(options = {}) ⇒ Object
81 82 83 |
# File 'lib/rspec-rayo/rayo/call.rb', line 81 def unjoin( = {}) write Punchblock::Command::Unjoin.new() end |
#unmute ⇒ Object
89 90 91 |
# File 'lib/rspec-rayo/rayo/call.rb', line 89 def unmute write Punchblock::Command::Unmute.new end |