Created
March 25, 2011 13:33
-
-
Save bdarcus/886834 to your computer and use it in GitHub Desktop.
little function to make a bib key based on data gleaned from rss feed data
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
# >> make_key('nytimes', '2011', 'Mapping the 2010 U.S. Census') | |
# => "nytimes:2011:mapping-2010-census" | |
def make_key(pubtoken, issued, title) | |
# first, split title into array, and throw out punctuation and short words | |
twords = title.scan(/\w+/).reject {|token| token.length < 4 } | |
# take first few resulting words, join and downcase | |
tslug = twords[0..3].join('-').downcase | |
return "#{pubtoken}:#{issued}:#{tslug}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment