Class: Baiwang::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/baiwang/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Result

Returns a new instance of Result.



75
76
77
78
79
# File 'lib/baiwang/request.rb', line 75

def initialize(data)
  @code = data['code'].to_i
  @data = data['response']
  @error = data['errorResponse']
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



73
74
75
# File 'lib/baiwang/request.rb', line 73

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



73
74
75
# File 'lib/baiwang/request.rb', line 73

def data
  @data
end

#errorObject (readonly)

Returns the value of attribute error.



73
74
75
# File 'lib/baiwang/request.rb', line 73

def error
  @error
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/baiwang/request.rb', line 81

def success?
  code.zero? && error.empty?
end