module Flare::Util::Result

Description

Result is a class for handling result code.

Constants

ClientError
Deleted
End
Error
Exists
Found
None
NotFound
NotStored
Ok
ServerError
Stored

Public Class Methods

result_of_string(string) click to toggle source

Converts a string representation of a request result to its result code.

# File lib/flare/util/result.rb, line 38
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) click to toggle source

Converts a result code to its string representation.

# File lib/flare/util/result.rb, line 26
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