Class: SMSTradeRB::Response
- Inherits:
-
Object
- Object
- SMSTradeRB::Response
- Defined in:
- lib/smstraderb/response.rb
Instance Method Summary collapse
- #code ⇒ Object
- #cost ⇒ Object
- #count ⇒ Object
- #error? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #message_id ⇒ Object
- #ok? ⇒ Boolean
- #response_message ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 |
# File 'lib/smstraderb/response.rb', line 8 def initialize(response) check_response_string(response) @code, @message_id, @cost, @count = response.split("\n") check_response_code end |
Instance Method Details
#code ⇒ Object
14 15 16 |
# File 'lib/smstraderb/response.rb', line 14 def code @code.to_i end |
#cost ⇒ Object
22 23 24 |
# File 'lib/smstraderb/response.rb', line 22 def cost blank?(@cost) ? nil : @cost.to_f end |
#count ⇒ Object
26 27 28 |
# File 'lib/smstraderb/response.rb', line 26 def count blank?(@count) ? nil : @count.to_i end |
#error? ⇒ Boolean
34 35 36 |
# File 'lib/smstraderb/response.rb', line 34 def error? !ok? end |
#message_id ⇒ Object
18 19 20 |
# File 'lib/smstraderb/response.rb', line 18 def blank?(@message_id) ? nil : @message_id end |
#ok? ⇒ Boolean
30 31 32 |
# File 'lib/smstraderb/response.rb', line 30 def ok? code == 100 end |
#response_message ⇒ Object
38 39 40 |
# File 'lib/smstraderb/response.rb', line 38 def SMSTradeRB::RESPONSE_CODES[code] end |