Sha256: e9b44aeeb6bf50c657b9c90f1cfd97aa015c3eea3880d44e67ed255bb76cb0d0

Contents?: true

Size: 568 Bytes

Versions: 15

Compression:

Stored size: 568 Bytes

Contents

class String
  def naive_split(pattern)
    string = self.dup
    found = []

    while position = string.index(pattern)
      found << string.slice!(0, position)
      string.slice!(0,[pattern.size,1].max)
    end

    found << string
    found
  end

  def tabs_to_spaces!
    gsub!("\t",' ' * Ruco::TAB_SIZE)
  end

  def leading_whitespace
    match(/^\s*/)[0]
  end

  # stub for 1.8
  unless method_defined?(:force_encoding)
    def force_encoding(encoding)
      self
    end
  end

  unless method_defined?(:ord)
    def ord
      bytes.first
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ruco-0.0.42 lib/ruco/core_ext/string.rb
ruco-0.0.41 lib/ruco/core_ext/string.rb
ruco-0.0.40 lib/ruco/core_ext/string.rb
ruco-0.0.39 lib/ruco/core_ext/string.rb
ruco-0.0.38 lib/ruco/core_ext/string.rb
ruco-0.0.37 lib/ruco/core_ext/string.rb
ruco-0.0.36 lib/ruco/core_ext/string.rb
ruco-0.0.35 lib/ruco/core_ext/string.rb
ruco-0.0.34 lib/ruco/core_ext/string.rb
ruco-0.0.33 lib/ruco/core_ext/string.rb
ruco-0.0.32 lib/ruco/core_ext/string.rb
ruco-0.0.31 lib/ruco/core_ext/string.rb
ruco-0.0.30 lib/ruco/core_ext/string.rb
ruco-0.0.29 lib/ruco/core_ext/string.rb
ruco-0.0.28 lib/ruco/core_ext/string.rb