lib/clamped/string.rb in clamped-0.1.0 vs lib/clamped/string.rb in clamped-1.0.0
- old
+ new
@@ -1,15 +1,16 @@
# frozen_string_literal: true
class String
- def clamped(whitelist, strict: true)
+ def clamped(whitelist, strict: true, default: nil)
is_included = proc do |item|
if strict
item == self
else
item.to_s == self
end
end
return self if whitelist.any?(is_included)
+ default
end
end