Module: Kosher
- Defined in:
- lib/kosher.rb
Constant Summary collapse
- VERSION =
'0.1.3'
- RULES =
File.open(File.join(File.dirname(__FILE__), "../data/rules.yml")) {|f| YAML.load(f)}
Class Method Summary collapse
-
.description?(product_group, description, language = :en) ⇒ Boolean
Check if a book description is kosher.
-
.seller?(venue, ave_feedback, total_feedback, feedback_threshold = 4.8) ⇒ Boolean
Check if a seller is kosher.
Class Method Details
.description?(product_group, description, language = :en) ⇒ Boolean
Check if a book description is kosher.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kosher.rb', line 10 def self.description?(product_group, description, language = :en) if RULES[language].is_a?(Hash) && RULES[language][product_group].is_a?(Array) RULES[language][product_group].each do |rule| if description =~ Regexp.new(rule["bad"], true) if rule["good"].nil? || description !~ Regexp.new(rule["good"], true) return false end end end end true end |
.seller?(venue, ave_feedback, total_feedback, feedback_threshold = 4.8) ⇒ Boolean
Check if a seller is kosher.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kosher.rb', line 24 def self.seller?(venue, ave_feedback, total_feedback, feedback_threshold = 4.8) # Give small sellers the benefit of doubt. if total_feedback == 0 true else if venue == :amazon if total_feedback < 5 ave_feedback > 4.4 ? true : false else ave_feedback >= feedback_threshold ? true : false end else # Other venues are not included at the moment. true end end end |