Sha256: a2b09402e823bbcd997e737b88309e5232cbbad84c4d0ee897a5fe586524a515
Contents?: true
Size: 524 Bytes
Versions: 15
Compression:
Stored size: 524 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
15 entries across 15 versions & 1 rubygems