Class: VoiceCom::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) {|_self| ... } ⇒ Response

Returns a new instance of Response.

Yields:

  • (_self)

Yield Parameters:



7
8
9
10
11
12
13
14
15
# File 'lib/voice_com/response.rb', line 7

def initialize(args = {})
  args.each do |k,v|
    k = k.strip.gsub("\s", "")
    instance_variable_set("@#{k.strip}", v)
  end
  yield self if block_given?
  validate!
  parse_answer
end

Instance Attribute Details

#answerObject

Returns the value of attribute answer.



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

def answer
  @answer
end

#answer_hashObject (readonly)

Returns the value of attribute answer_hash.



5
6
7
# File 'lib/voice_com/response.rb', line 5

def answer_hash
  @answer_hash
end

#dlrObject

Returns the value of attribute dlr.



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

def dlr
  @dlr
end

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

#sidObject

Returns the value of attribute sid.



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

def sid
  @sid
end

#smsIDObject

Returns the value of attribute smsID.



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

def smsID
  @smsID
end

#toObject

Returns the value of attribute to.



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

def to
  @to
end

#tsObject

Returns the value of attribute ts.



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

def ts
  @ts
end

#voicecom_idObject

Returns the value of attribute voicecom_id.



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

def voicecom_id
  @voicecom_id
end

Instance Method Details

#get_answerObject



25
26
27
# File 'lib/voice_com/response.rb', line 25

def get_answer
  Hash[@answer.split("+").map{|x| x.split(":")}]
end

#parse_answerObject



21
22
23
# File 'lib/voice_com/response.rb', line 21

def parse_answer
  @answer_hash = get_answer
end

#sms_idObject



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

def sms_id
  @dlr
end

#success?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/voice_com/response.rb', line 30

def success?
  dlr.to_i == 1
end