Class: ActionTexter::Response Abstract
- Inherits:
-
Object
- Object
- ActionTexter::Response
- Defined in:
- lib/action_texter/response.rb
Overview
This class is abstract.
A response as sent from the provider.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error_message ⇒ String
A descriptive message of the error when an error happened.
-
#raw ⇒ String
readonly
The raw response as returned by the provider.
-
#success ⇒ Boolean
Weather sending the message succeeded or not.
Instance Method Summary collapse
-
#failed? ⇒ Boolean
False when sending the message failed, true otherwise.
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
True when sending the message succeeded, false otherwise.
- #to_s ⇒ Object
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
16 17 18 19 |
# File 'lib/action_texter/response.rb', line 16 def initialize(raw) @raw = raw process_response(raw) end |
Instance Attribute Details
#error_message ⇒ String
Returns a descriptive message of the error when an error happened.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/action_texter/response.rb', line 13 class ActionTexter::Response attr_reader :raw, :success, :error_message def initialize(raw) @raw = raw process_response(raw) end # @return [Boolean] true when sending the message succeeded, false otherwise. def success? !!@success end # @return [Boolean] false when sending the message failed, true otherwise. def failed? !@success end # @private def to_s "#<#{self.class.name}:#{object_id}:#{@success ? "success" : "fail"}>" end private def process_response(raw) raise NotImplementedError.new("should be implemented by subclasses") end end |
#raw ⇒ String (readonly)
Returns the raw response as returned by the provider.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/action_texter/response.rb', line 13 class ActionTexter::Response attr_reader :raw, :success, :error_message def initialize(raw) @raw = raw process_response(raw) end # @return [Boolean] true when sending the message succeeded, false otherwise. def success? !!@success end # @return [Boolean] false when sending the message failed, true otherwise. def failed? !@success end # @private def to_s "#<#{self.class.name}:#{object_id}:#{@success ? "success" : "fail"}>" end private def process_response(raw) raise NotImplementedError.new("should be implemented by subclasses") end end |
#success ⇒ Boolean
Returns weather sending the message succeeded or not. See #success? and #failed?.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/action_texter/response.rb', line 13 class ActionTexter::Response attr_reader :raw, :success, :error_message def initialize(raw) @raw = raw process_response(raw) end # @return [Boolean] true when sending the message succeeded, false otherwise. def success? !!@success end # @return [Boolean] false when sending the message failed, true otherwise. def failed? !@success end # @private def to_s "#<#{self.class.name}:#{object_id}:#{@success ? "success" : "fail"}>" end private def process_response(raw) raise NotImplementedError.new("should be implemented by subclasses") end end |
Instance Method Details
#failed? ⇒ Boolean
Returns false when sending the message failed, true otherwise.
27 28 29 |
# File 'lib/action_texter/response.rb', line 27 def failed? !@success end |
#success? ⇒ Boolean
Returns true when sending the message succeeded, false otherwise.
22 23 24 |
# File 'lib/action_texter/response.rb', line 22 def success? !!@success end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/action_texter/response.rb', line 32 def to_s "#<#{self.class.name}:#{object_id}:#{@success ? "success" : "fail"}>" end |