Sha256: 23cf1bc889ebe60fc3b24e8b0a5945d4c3be2bd7d9d9f5e45d2ea21d861ace44
Contents?: true
Size: 522 Bytes
Versions: 83
Compression:
Stored size: 522 Bytes
Contents
class Object def blank? respond_to?(:empty?) ? empty? : !self end def present? !blank? end end class String def to_bool return true if self == true || self =~ (/(true|t|yes|y|x|1)$/i) return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i) raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") end def format_date_time(date_time_format) return if self.blank? new_date = DateTime.parse(self) new_date.strftime(date_time_format) end end
Version data entries
83 entries across 83 versions & 1 rubygems