Sha256: f75ad3a3ab8f45f4fb896a818b1a13ffeb51c4de2c16350082360d7a2f0ebdcb
Contents?: true
Size: 1.08 KB
Versions: 18
Compression:
Stored size: 1.08 KB
Contents
# typed: false # frozen_string_literal: true module Workato module Extension module Object # rubocop:disable Naming/PredicateName def is_true?(null_true: false) if is_a?(::String) return true if (self =~ (/\A(true|t|yes|y|1)\Z/i)).present? return false if (self =~ (/\A(false|f|no|n|0)\Z/i)).present? raise "Can't convert empty string to boolean" if blank? raise "Can't convert string value #{self} to boolean" elsif is_a?(::Integer) return true if self == 1 return false if zero? raise "Can't convert number value #{self} to boolean" elsif is_a?(::TrueClass) true elsif is_a?(::FalseClass) false elsif is_a?(::NilClass) null_true == true else raise "Can't convert type #{self.class.name} to boolean" end end def is_not_true?(null_not_true: true) !is_true?(null_true: !null_not_true) end # rubocop:enable Naming/PredicateName end end end Object.include(Workato::Extension::Object)
Version data entries
18 entries across 18 versions & 1 rubygems