Sha256: 6a4cc7fee723fe413491fec7def204836f1b84dba71e38817bcb39d2a6024b81

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

## String#trim

    require 'facets/string/trim'

    s = %q{
          |ABC
          |123
          |TEST
          }.trim
    s.assert == "ABC\n123\nTEST"

    s = %q{
            |ABC
          |123
                |TEST
          }.trim
    s.assert == "ABC\n123\nTEST"

    s = %q{|ABC
          |123
          |TEST
    }.trim
    s.assert == "ABC\n123\nTEST"

    s = %q{
          |ABC
          |123
          |TEST}.trim
    s.assert == "ABC\n123\nTEST"

    s = %q{|ABC
          |123
          |TEST}.trim
    s.assert == "ABC\n123\nTEST"

    s = %q{   |ABC
          |123
          |TEST}.trim
    s.assert == "ABC\n123\nTEST"

    s = %q{ABC
          |123
          |TEST
          }.trim
    s.assert == "ABC\n123\nTEST"

spacing

    s = %q{
          | ABC
          | 123
          | TEST
          }.trim
    s.assert == " ABC\n 123\n TEST"

    s = %q{
          |ABC
          |123
          |TEST
          }.trim(1)
    s.assert == " ABC\n 123\n TEST"

    s = %q{
          |ABC
          |123
          |TEST
          }.trim(2)
    s.assert == "  ABC\n  123\n  TEST"

    s = %q{ ABC
          - 123
          - TEST
          }.trim
    s.assert == " ABC\n 123\n TEST"

random placement

    @volly = {}
    100.times{ |n|
      k = []
      a = []
      5.times{ |i|
        k << ( ( ' ' * Integer(rand*10) ) + '|' + i.to_s )
        a << ( i.to_s )
      }
      @volly[k.join("\n")] = a.join("\n")
    }

    @volly.each{ |k,v|
      k.trim.assert == v
    }

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 demo/core/string/trim.md
facets-3.1.0 demo/core/string/trim.md