Sha256: 67e789501e4895146efeb500bf3370e16cd7b5d81bf9970296233ad05cf7dc9f

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

== String#margin

    require 'facets/string/margin'

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

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

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

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

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

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

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

spacing

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

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

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

    s = %q{ ABC
          - 123
          - TEST
          }.margin
    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.margin.assert == v
    }

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-3.0.0 demo/core/string/margin.rdoc
facets-2.9.3 qed/core/string/margin.rdoc
facets-2.9.2 qed/core/string/margin.rdoc
facets-2.9.1 qed/core/string/margin.rdoc
facets-2.9.0 qed/core/string/margin.rdoc
facets-2.9.0.pre.2 qed/core/string/margin.rdoc
facets-2.9.0.pre.1 qed/core/string/margin.rdoc