Sha256: be3f2dc3ae5d8e5a61f7c553f283c25477bed48d50f835acd04e74027fd73036
Contents?: true
Size: 986 Bytes
Versions: 4
Compression:
Stored size: 986 Bytes
Contents
module Kosher class Description < Struct.new(:text) DAMAGED = "\\b(?:missing|torn|broken|split|discard|withdrawn|rent|stain|school|damaged|water)" EXLIB = "(?:e?x|discarded|retired|former|has|have)[\\s._-]*lib" MARKED = "(highlight|hilit|underlin)" MISSING_VOL = "(vols?|volume) only" REVIEW_COPY = "\\b(?:uncorrected|advanced?\\sreview|arc)\\b" def damaged? matches?(DAMAGED) end def ex_lib? matches?(EXLIB) && !matches?(negation_of(EXLIB)) end def kosher? !(damaged? || ex_lib? || marked? || missing_volume? || review_copy?) end def marked? matches?(MARKED) && !matches?(negation_of(MARKED)) end def missing_volume? matches?(MISSING_VOL) end def review_copy? matches?(REVIEW_COPY) end private def matches?(value) !!text.match(Regexp.new(value, true)) end def negation_of(value) "(?:no|not an?)\\s+#{value}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kosher-0.2.24 | lib/kosher/description.rb |
kosher-0.2.23 | lib/kosher/description.rb |
kosher-0.2.22 | lib/kosher/description.rb |
kosher-0.2.21 | lib/kosher/description.rb |