Skip to content

Instantly share code, notes, and snippets.

@szymonbaranowski

szymonbaranowski/likelihood.rb Secret

Last active Mar 12, 2016
Embed
What would you like to do?
module Services
module Validators
class Likelihood
RESPONSES = {
unknown: 0,
very_unlikely: 1,
unlikely: 2,
possible: 3,
likely: 4,
very_likely: 5,
}.freeze
private_constant :RESPONSES
def initialize(response, threshold)
@response, @threshold = response, threshold
end
def call
value_for(@response) > value_for(@threshold)
end
private
def value_for(response)
RESPONSES.fetch(response.downcase.to_sym)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.