Method: Webhookdb.parse_bool

Defined in:
lib/webhookdb.rb

.parse_bool(s) ⇒ Object

Raises:

  • (ArgumentError)


208
209
210
211
212
213
214
215
216
217
# File 'lib/webhookdb.rb', line 208

def self.parse_bool(s)
  # rubocop:disable Style/NumericPredicate
  return false if s == nil? || s.blank? || s == 0
  # rubocop:enable Style/NumericPredicate
  return true if s.is_a?(Integer)
  sb = s.to_s.downcase
  return true if ["true", "t", "yes", "y", "on", "1"].include?(sb)
  return false if ["false", "f", "no", "n", "off", "0"].include?(sb)
  raise ArgumentError, "unparseable bool: #{s.inspect}"
end