Class: String

Inherits:
Object show all
Defined in:
lib/ruco/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#force_encoding(encoding) ⇒ Object



17
18
19
# File 'lib/ruco/core_ext/string.rb', line 17

def force_encoding(encoding)
  self
end

#naive_split(pattern) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/ruco/core_ext/string.rb', line 2

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