Class: ReceiveChar
Instance Method Summary
collapse
#command, #command_error?, #message, #result, #return_code, #to_s
Constructor Details
#initialize(command, response) ⇒ ReceiveChar
Returns a new instance of ReceiveChar.
44
45
46
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 44
def initialize(command, response)
super(command, response)
end
|
Instance Method Details
#char ⇒ Object
94
95
96
97
98
99
100
101
102
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 94
def char
if result == '0'
return nil
elsif not failure?
return result.to_i.chr
else
return nil
end
end
|
#error? ⇒ Boolean
104
105
106
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 104
def error?
return command_error?
end
|
#failure? ⇒ Boolean
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 82
def failure?
if @is_failure.nil?
if result == '-1'
@is_failure = true
else
@is_failure = false
end
end
return @is_failure
end
|
#hangup? ⇒ Boolean
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 61
def hangup?
if @is_hangup.nil?
rgx = Regexp.new(/\(hangup\)$/)
if rgx.match(response)
@is_hangup = true
if not failure?
raise(UnknownError, "Please report to [email protected] with as much information as you can provide")
end
else
@is_hangup = false
end
end
return @is_hangup
end
|
#response ⇒ Object
108
109
110
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 108
def response
return message
end
|
#success? ⇒ Boolean
78
79
80
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 78
def success?
return ((not timeout?) and (not failure?))
end
|
#timeout? ⇒ Boolean
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/ruby-agi/rs/receive_char.rb', line 48
def timeout?
if @is_timeout.nil?
rgx = Regexp.new(/\(timeout\)$/)
if rgx.match(response)
@is_timeout = true
else
@is_timeout = false
end
end
return @is_timeout
end
|