Class: ChannelStatus

Inherits:
ReturnStatus show all
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

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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


95
96
97
# File 'lib/ruby-agi/rs/channel_status.rb', line 95

def dialed?
  return result == '3'
end

#error?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/ruby-agi/rs/channel_status.rb', line 119

def error?
  return command_error?
end

#failure?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


85
86
87
# File 'lib/ruby-agi/rs/channel_status.rb', line 85

def reserved?
  return result == '1'
end

#responseObject



123
124
125
# File 'lib/ruby-agi/rs/channel_status.rb', line 123

def response
  return message
end

#ringing?Boolean

4 Line is ringing

Returns:

  • (Boolean)


100
101
102
# File 'lib/ruby-agi/rs/channel_status.rb', line 100

def ringing?
  return result == '4'
end

#success?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


110
111
112
# File 'lib/ruby-agi/rs/channel_status.rb', line 110

def up?
  return result == '6'
end