Class: WaitForDigit

Inherits:
ReturnStatus show all
Defined in:
lib/ruby-agi/rs/wait_for_digit.rb

Instance Method Summary collapse

Methods inherited from ReturnStatus

#command, #command_error?, #message, #result, #return_code, #to_s

Constructor Details

#initialize(command, response) ⇒ WaitForDigit

Returns a new instance of WaitForDigit.



42
43
44
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 42

def initialize(command, response)
  super(command, response)
end

Instance Method Details

#digitObject



70
71
72
73
74
75
76
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 70

def digit
  if success?
    return result.to_i.chr
  else
    return nil
  end
end

#error?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 82

def error?
  return command_error?
end

#failure?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 46

def failure?
  if @is_failure.nil?
    if result == '-1'
      @is_failure = true
    else
      @is_failure = false
    end 
  end

  return @is_failure
end

#responseObject



86
87
88
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 86

def response
  return message
end

#success?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 78

def success?
  return ((not timeout?) and (not failure?))
end

#timeout?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ruby-agi/rs/wait_for_digit.rb', line 58

def timeout?
  if @is_timeout.nil?
    if result == '0'
      @is_timeout = true
    else
      @is_timeout = false
    end 
  end

  return @is_timeout
end