Sha256: 48e5db7c0f130efb7ac2bf3484077c39e55ff9a3b5f3df8879e3a535b824c5eb

Contents?: true

Size: 406 Bytes

Versions: 24

Compression:

Stored size: 406 Bytes

Contents

require File.dirname(__FILE__) + '/time'

class String
  def coerce
    return true if self == 'true'
    return false if self == 'false'
    coerce_try { return Time.iso8601(self) }
    coerce_try { return Integer(self) }
    coerce_try { return Float(self) }
    self
  end

  def strip_html
    gsub(/<(?:[^>'"]*|(['"]).*?\1)*>/,'')
  end

private

  def coerce_try
    yield
  rescue
    nil
  end
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
calagator-1.0.0 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.9 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.8 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.7 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.6 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.5 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.3 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.2 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
grokus-1.0.0.1 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
calagator-1.0.0.rc3 vendor/gems/mofo-0.2.8/lib/microformat/string.rb
mofo-0.2.5 ./lib/microformat/string.rb
mofo-0.2.6 ./lib/microformat/string.rb
mofo-0.2.10 ./lib/microformat/string.rb
mofo-0.2.11 ./lib/microformat/string.rb
mofo-0.2.12 ./lib/microformat/string.rb
mofo-0.2.13 ./lib/microformat/string.rb
mofo-0.2.14 ./lib/microformat/string.rb
mofo-0.2.15 ./lib/microformat/string.rb
mofo-0.2.16 ./lib/microformat/string.rb
mofo-0.2.2 lib/microformat/string.rb