Skip to content

Instantly share code, notes, and snippets.

@bdarcus
Created March 25, 2011 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdarcus/886834 to your computer and use it in GitHub Desktop.
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
# >> 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