crnixon (owner)

Revisions

  • c94fef crnixon Fri Sep 19 07:06:42 -0700 2008
gist: 11591 Download_button fork
public
Public Clone URL: git://gist.github.com/11591.git
Embed All Files: show embed
Text #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class String
  def char_split(chars)
    parser = lambda do |line, results|
      line.index(chars) == nil \
      ? line.length > 0 \
        ? results << line \
        : results \
      : line.index(chars) == 0 \
        ? parser[line[chars.length..-1], results] \
        : parser[line[line.index(chars) + chars.length..-1], results << line[0..line.index(chars) - 1]]
    end
    
    parser[self.dup, Array.new]
  end
end