Module: Flare::Util::Result
- Included in:
- Net::Connection, Tools::Client
- Defined in:
- lib/flare/util/result.rb
Overview
Description
Result is a class for handling result code.
Constant Summary collapse
- None =
nil
- Ok =
:OK
- End =
:END
- Stored =
:STORED
- NotStored =
:NOT_STORED
- Exists =
:EXISTS
- NotFound =
:NOT_FOUND
- Deleted =
:DELETED
- Found =
:FOUND
- Error =
:ERROR
- ClientError =
:CLIENT_ERROR
- ServerError =
:SERVER_ERROR
Class Method Summary collapse
-
.result_of_string(string) ⇒ Object
Converts a string representation of a request result to its result code.
-
.string_of_result(result) ⇒ Object
Converts a result code to its string representation.
Class Method Details
.result_of_string(string) ⇒ Object
Converts a string representation of a request result to its result code.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/flare/util/result.rb', line 39 def self.result_of_string(string) case string when "" None else [Ok,End,Stored,NotStored,Exists,NotFound,Deleted,Found,Error,ClientError,ServerError].each do |x| return x if x.to_s == string end raise "Invalid arugument '"+string.to_s+"'" end end |
.string_of_result(result) ⇒ Object
Converts a result code to its string representation.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/flare/util/result.rb', line 27 def self.string_of_result(result) case result when None "" when Ok,End,Stored,NotStored,Exists,NotFound,Deleted,Found,Error,ClientError,ServerError result.to_s else raise "Invalid argument '"+result.to_s+"'" end end |