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:
evazion
2018-05-03 18:53:35 -05:00
parent 96669ca4b5
commit c7492343ce
15 changed files with 62 additions and 102 deletions

View File

@@ -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