Class: Dingtalk::ResultHandler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, en_msg, result = {}) ⇒ ResultHandler

Returns a new instance of ResultHandler.



5
6
7
8
9
10
# File 'lib/dingtalk/handler/result_handler.rb', line 5

def initialize(code, en_msg, result={})
  @code = code || OK_CODE
  @en_msg = en_msg || OK_MSG
  @cn_msg = GLOBAL_CODES[@code.to_i]
  @result = package_result(result)
end

Instance Attribute Details

#cn_msgObject

Returns the value of attribute cn_msg.



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

def cn_msg
  @cn_msg
end

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

#en_msgObject

Returns the value of attribute en_msg.



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

def en_msg
  @en_msg
end

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

Instance Method Details

#full_error_messageObject Also known as: full_error_messages



22
23
24
# File 'lib/dingtalk/handler/result_handler.rb', line 22

def full_error_message
  full_message if !is_ok?
end

#full_messageObject Also known as: full_messages



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

def full_message
  "#{code}: #{en_msg}(#{cn_msg})."
end

#is_ok?Boolean Also known as: ok?

Returns:

  • (Boolean)


12
13
14
# File 'lib/dingtalk/handler/result_handler.rb', line 12

def is_ok?
  code == OK_CODE
end