Sha256: 9628e256cc21f9bd843cedd3ddba6cfefec1dbc9e12532e835abf75c63f00503
Contents?: true
Size: 790 Bytes
Versions: 3
Compression:
Stored size: 790 Bytes
Contents
class Soba::Mieruka class Response OK = 'OK' NG = 'NG' def self.parse(res_body) doc = REXML::Document.new(res_body) if doc.root.attributes['result'] == 'OK' return Response.new(OK, doc) else errorElm = doc.root.elements['error'] res = Response.new(NG, nil) res.error_code = errorElm.attributes['code'] res.error_message = CGI.unescapeHTML(errorElm.attributes['message']) return res end end attr_accessor :error_code, :error_message def initialize(result, value, message=nil) @result = result @value = value @message = message end def success? @result != NG end attr_reader :value, :message end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
soba-mieruka-0.0.4 | lib/soba/mieruka/response.rb |
soba-mieruka-0.0.3 | lib/soba/mieruka/response.rb |
soba-mieruka-0.0.2 | lib/soba/mieruka/response.rb |