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

Version Path
testcentricity_web-0.7.8 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.7 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.6 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.5 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.4 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.3 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.7.0 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.9 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.8 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.7 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.6.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.6 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.5 lib/testcentricity_web/utility_helpers.rb