Sha256: 4d429ef509b5d46f76a5279504c1e918574d05890be5c9ac24e76d3588094b6e
Contents?: true
Size: 1.15 KB
Versions: 14
Compression:
Stored size: 1.15 KB
Contents
module Kosher class Description < String 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 kosher? !(present? && bad?) end private def bad? damaged? || ex_library? || marked? || missing_volume? || review_copy? end def damaged? matches(DAMAGED) end def does_not_match(value) !match(Regexp.new(value, true)) end def ex_library? matches(EXLIB) && does_not_match(negation_of(EXLIB)) end def marked? matches(MARKED) && does_not_match(negation_of(MARKED)) end def matches(value) !does_not_match(value) end def missing_volume? matches(MISSING_VOL) end def negation_of(value) "(?:no|not an?)\\s+#{value}" end def present? self != '' end def review_copy? matches(REVIEW_COPY) end end end
Version data entries
14 entries across 14 versions & 2 rubygems