Sha256: e17a9ee98fff815f1637c2b55fbbf249e81ecbde4aa45dfe0336d7a1527d9966

Contents?: true

Size: 500 Bytes

Versions: 18

Compression:

Stored size: 500 Bytes

Contents

#--
# Author::    Tyler Rick
# Copyright:: Copyright (c) 2007 QualitySmith, Inc.
# License::   Ruby License
# Submit to Facets?:: Yes
#++

class String
  # Strips out everything except digits.
  def digits_only
    self.gsub(/[^0-9]/, "")
  end
end

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test
class TheTest < Test::Unit::TestCase
  def test_digits_only
    assert_equal "123", "$!@)(*&abc123[]{}".digits_only
  end
end
=end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
quality_extensions-0.1.4 lib/quality_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.13 lib/qualitysmith_extensions/string/digits_only.rb
quality_extensions-0.1.2 lib/quality_extensions/string/digits_only.rb
quality_extensions-0.1.1 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.4 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.6 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.64 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.5 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.24 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.29 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.17 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.7 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.34 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.49 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.63 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.20 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.33 lib/qualitysmith_extensions/string/digits_only.rb
qualitysmith_extensions-0.0.60 lib/qualitysmith_extensions/string/digits_only.rb