Class: ReturnStatus
- Inherits:
-
Object
- Object
- ReturnStatus
- Defined in:
- lib/erichmond-ruby-agi/return_status.rb
Overview
every method of this class would return string or boolean
methods of command class usually return ReturnStatus object
Instance Method Summary collapse
- #command_error? ⇒ Boolean
- #digit ⇒ Object
- #digits ⇒ Object
-
#initialize(command, message) ⇒ ReturnStatus
constructor
A new instance of ReturnStatus.
- #message ⇒ Object
- #result ⇒ Object
- #timeout? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(command, message) ⇒ ReturnStatus
Returns a new instance of ReturnStatus.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 29 def initialize(command, ) @command = command.chomp @message = @result = nil @digit = nil @digits = nil @return_code = nil @command_error = false if .nil? @messsage = "No responses !!" else str = @message.split(' ') @return_code = str[0] if @return_code == '200' @result = str[1].split('=')[1] end end end |
Instance Method Details
#command_error? ⇒ Boolean
79 80 81 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 79 def command_error? return (result.nil? or (not (@return_code == '200'))) end |
#digit ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 60 def digit if (@result == '0') return nil else return @result.to_i.chr end end |
#digits ⇒ Object
69 70 71 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 69 def digits return @result.to_s end |
#message ⇒ Object
74 75 76 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 74 def return @message.to_s end |
#result ⇒ Object
55 56 57 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 55 def result return @result.to_s end |
#timeout? ⇒ Boolean
84 85 86 87 88 89 90 91 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 84 def timeout? rgx = Regexp.new(/\(timeout\)/) if rgx.match(@message) return true else return false end end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/erichmond-ruby-agi/return_status.rb', line 50 def to_s return @command.to_s + ' >> ' + @message.to_s end |