Class: Mobitex::Status
- Inherits:
-
Object
- Object
- Mobitex::Status
- Defined in:
- lib/mobitex/status.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
-
.parse(raw_status) ⇒ Object
Public: Parses single raw status from Mobitex response.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(attributes = {}) ⇒ Status
constructor
A new instance of Status.
- #number ⇒ Object
- #status ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Status
Returns a new instance of Status.
27 28 29 |
# File 'lib/mobitex/status.rb', line 27 def initialize(attributes = {}) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/mobitex/status.rb', line 4 def attributes @attributes end |
Class Method Details
.parse(raw_status) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mobitex/status.rb', line 16 def self.parse(raw_status) attributes = {} raw_status.to_s.split(',').map do |raw_attribute| part = raw_attribute.partition(':') attributes[part.first.strip] = part.last.strip end new(attributes) end |
Instance Method Details
#id ⇒ Object
35 36 37 |
# File 'lib/mobitex/status.rb', line 35 def id attributes['Id'] end |
#number ⇒ Object
39 40 41 |
# File 'lib/mobitex/status.rb', line 39 def number attributes['Number'] end |
#status ⇒ Object
31 32 33 |
# File 'lib/mobitex/status.rb', line 31 def status attributes['Status'] end |
#valid? ⇒ Boolean
43 44 45 |
# File 'lib/mobitex/status.rb', line 43 def valid? status == '002' end |