class Ribeye
Constants
- BLOOM_FILTER_DOES_NOT_EXIST
- BLOOM_FILTER_EXISTS
- FALSE_VALUE
- INVALID_PARAMETERS
- INVALID_PARAMETER_VALUE
- SUCCESS
- TRUE_VALUE
Response codes
Attributes
client[RW]
uri[RW]
Public Class Methods
new(uri = nil)
click to toggle source
# File lib/ribeye.rb, line 23 def initialize(uri = nil) @uri = uri || 'http://localhost:8080' @client = HTTPClient.new end
Public Instance Methods
check(name, value)
click to toggle source
# File lib/ribeye.rb, line 63 def check(name, value) make_request('/check', TRUE_VALUE, name: name, value: value) end
create(name, size)
click to toggle source
# File lib/ribeye.rb, line 47 def create(name, size) make_request('/create', SUCCESS, name: name, size: size) end
delete(name)
click to toggle source
# File lib/ribeye.rb, line 51 def delete(name) make_request('/delete', SUCCESS, name: name) end
exists(name)
click to toggle source
# File lib/ribeye.rb, line 55 def exists(name) make_request('/exists', TRUE_VALUE, name: name) end
insert(name, value)
click to toggle source
# File lib/ribeye.rb, line 59 def insert(name, value) make_request('/insert', SUCCESS, name: name, value: value) end
make_request(path, success_value, params)
click to toggle source
# File lib/ribeye.rb, line 41 def make_request(path, success_value, params) response = client.get(URI.join(uri, path), params) parse_errors(response.body) response.body == success_value end
parse_errors(body)
click to toggle source
# File lib/ribeye.rb, line 28 def parse_errors(body) case body when INVALID_PARAMETER_VALUE raise InvalidParameterValue when INVALID_PARAMETERS raise InvalidParameters when BLOOM_FILTER_EXISTS raise BFExists when BLOOM_FILTER_DOES_NOT_EXIST raise NonExistentBF end end