Class: Bulksms::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/bulksms/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, result, batch_id) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
# File 'lib/bulksms/response.rb', line 6

def initialize(code, result, batch_id)
  @code      = code
  @result    = result
  @batch_id  = batch_id
end

Instance Attribute Details

#batch_idObject (readonly)

Returns the value of attribute batch_id.



4
5
6
# File 'lib/bulksms/response.rb', line 4

def batch_id
  @batch_id
end

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/bulksms/response.rb', line 4

def code
  @code
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/bulksms/response.rb', line 4

def result
  @result
end

Class Method Details

.parse(response_text) ⇒ Object



16
17
18
19
# File 'lib/bulksms/response.rb', line 16

def self.parse(response_text)
  tokens = response_text.split('|')
  new tokens[0].to_i, tokens[1], tokens[2].to_i
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/bulksms/response.rb', line 12

def success?
  @code == 0
end