Created
October 6, 2008 12:35
-
-
Save apeiros/15036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def segments | |
segments = split(/\./) | |
while segments.size > 1 | |
yield(segments.join('.')) | |
segments.pop | |
end | |
yield('.') | |
end | |
end | |
class String | |
def segments | |
str = dup | |
begin | |
yield(str) | |
end while str.sub!(/\.[^.]+$/, '') | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment