Class: ChannelStatus
- Inherits:
-
ReturnStatus
- Object
- ReturnStatus
- ChannelStatus
- Defined in:
- lib/ruby-agi/rs/channel_status.rb
Constant Summary collapse
- VALID_STATUS =
['0', '1', '2', '3', '4', '5', '6', '7']
Instance Method Summary collapse
-
#available? ⇒ Boolean
0 Channel is down and available.
-
#busy? ⇒ Boolean
7 Line is busy.
-
#dialed? ⇒ Boolean
3 Digits (or equivalent) have been dialed.
- #error? ⇒ Boolean
- #failure? ⇒ Boolean
-
#initialize(command, response) ⇒ ChannelStatus
constructor
A new instance of ChannelStatus.
-
#off_hook? ⇒ Boolean
2 Channel is off hook.
-
#remote_ringing? ⇒ Boolean
5 Remote end is ringing.
-
#reserved? ⇒ Boolean
1 Channel is down, but reserved.
- #response ⇒ Object
-
#ringing? ⇒ Boolean
4 Line is ringing.
- #success? ⇒ Boolean
-
#up? ⇒ Boolean
6 Line is up.
Methods inherited from ReturnStatus
#command, #command_error?, #message, #result, #return_code, #to_s
Constructor Details
#initialize(command, response) ⇒ ChannelStatus
Returns a new instance of ChannelStatus.
51 52 53 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 51 def initialize(command, response) super(command, response) end |
Instance Method Details
#available? ⇒ Boolean
0 Channel is down and available
80 81 82 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 80 def available? return result == '0' end |
#busy? ⇒ Boolean
7 Line is busy
115 116 117 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 115 def busy? return result == '7' end |
#dialed? ⇒ Boolean
3 Digits (or equivalent) have been dialed
95 96 97 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 95 def dialed? return result == '3' end |
#error? ⇒ Boolean
119 120 121 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 119 def error? return command_error? end |
#failure? ⇒ Boolean
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 67 def failure? if @is_failure.nil? if result == '-1' @is_failure = true else @is_failure = false end end return @is_failure end |
#off_hook? ⇒ Boolean
2 Channel is off hook
90 91 92 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 90 def off_hook? return result == '2' end |
#remote_ringing? ⇒ Boolean
5 Remote end is ringing
105 106 107 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 105 def remote_ringing? return result == '5' end |
#reserved? ⇒ Boolean
1 Channel is down, but reserved
85 86 87 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 85 def reserved? return result == '1' end |
#response ⇒ Object
123 124 125 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 123 def response return end |
#ringing? ⇒ Boolean
4 Line is ringing
100 101 102 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 100 def ringing? return result == '4' end |
#success? ⇒ Boolean
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 55 def success? if not failure? if VALID_STATUS.include?(result) @is_success = true else @is_success = false end end return @is_success end |
#up? ⇒ Boolean
6 Line is up
110 111 112 |
# File 'lib/ruby-agi/rs/channel_status.rb', line 110 def up? return result == '6' end |