Last active
December 13, 2015 20:08
-
-
Save cktricky/4967248 to your computer and use it in GitHub Desktop.
crappy solution for parsing sources from a string
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
require 'uri' | |
a = %{rubygems repository http://blahblah.net/, https://rubygems.org/} | |
b = a.split().inject([]) {|array, string| | |
begin | |
x = URI.parse(string).absolute? | |
array << string if x | |
rescue | |
end | |
array | |
} | |
puts b | |
# ALTERNATIVELY, just use this line | |
b = a.split().select {|x| x if URI.parse(x).absolute?} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment