Create a gist now

Instantly share code, notes, and snippets.

little function to make a bib key based on data gleaned from rss feed data
# >> 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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment