String: add truthy? & falsy? core extensions.
* Add `truthy?` and `falsy?` core extensions to String. * Use `truthy?` and `falsy?` to replace ad-hoc parsing of boolean parameters in various places.
This commit is contained in:
@@ -23,6 +23,14 @@ module Danbooru
|
||||
def to_escaped_for_tsquery
|
||||
"'#{gsub(/\0/, '').gsub(/'/, '\0\0').gsub(/\\/, '\0\0\0\0')}'"
|
||||
end
|
||||
|
||||
def truthy?
|
||||
self.match?(/\A(true|t|yes|y|on|1)\z/i)
|
||||
end
|
||||
|
||||
def falsy?
|
||||
self.match?(/\A(false|f|no|n|off|0)\z/i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user