Class: YunTongXun::ResultHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/yun_tong_xun/result_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ ResultHandler

Returns a new instance of ResultHandler.



4
5
6
7
# File 'lib/yun_tong_xun/result_handler.rb', line 4

def initialize(raw)
  @raw = raw
  @json = JSON.parse(raw)
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



3
4
5
# File 'lib/yun_tong_xun/result_handler.rb', line 3

def json
  @json
end

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/yun_tong_xun/result_handler.rb', line 3

def raw
  @raw
end

Instance Method Details

#codeObject



13
14
15
# File 'lib/yun_tong_xun/result_handler.rb', line 13

def code
  json['statusCode']
end

#msgObject



17
18
19
# File 'lib/yun_tong_xun/result_handler.rb', line 17

def msg
  json['statusMsg']
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/yun_tong_xun/result_handler.rb', line 9

def valid?
  code == '000000'
end