Sha256: 0a90175771c5e20dc739d0a1ac4760ed5a75acf3ea309d0e97c858a0d514af52

Contents?: true

Size: 772 Bytes

Versions: 7

Compression:

Stored size: 772 Bytes

Contents

class String

  # Like push but works from the other end of the string.
  def slap( str=' ' )
    insert(0, str)
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCString < Test::Unit::TestCase

    def setup
      @a =  ""
    end

    def test_001
      #assert_raises( ArgumentError ) { @a.slap }
      assert_raises( ArgumentError ) { @a.slap(1,2) }
    end

    def test_002
      assert_equal( "0", @a.slap("0") )
      assert_equal( "10", @a.slap("1") )
      assert_equal( "210", @a.slap("2") )
      assert_equal( "3210", @a.slap("3") )
      assert_equal( "43210", @a.slap("4") )
      assert_equal( "543210", @a.slap("5") )
    end

  end

=end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-0.9.0 lib/nano/string/slap.rb
facets-1.0.0 lib/facet/string/slap.rb
facets-1.0.3 packages/core/lib/facet/string/slap.rb
facets-1.1.0 lib/facet/string/slap.rb
facets-1.2.0 lib/facets/core/string/slap.rb
facets-1.2.1 lib/facets/core/string/slap.rb
facets-1.3.0 lib/facets/core/string/slap.rb