Sha256: 2332a1ecc87cb1a9cc9b29179d674cfc5aea68cc4c2fee97b47f4ed8a715999b

Contents?: true

Size: 640 Bytes

Versions: 53

Compression:

Stored size: 640 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 string_between(marker1, marker2)
    self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
  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

53 entries across 53 versions & 2 rubygems

Version Path
testcentricity-2.3.13 lib/testcentricity/utility_helpers.rb
testcentricity_web-2.3.12 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.11 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.10 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.9 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.8 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.7 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.6.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.6.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.6 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.5 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.4 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.3 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.3.0 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.2.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.2.0 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.1.10 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-2.1.9 lib/testcentricity_web/utility_helpers.rb