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

Version Path
testcentricity_web-2.0.19 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.18 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.17 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.16 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.15 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.14 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.13 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.12 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.11 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.10 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.9 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.8 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.7 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.6 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.5 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.4 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.3 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.0.0 lib/testcentricity_web/utility_helpers.rb