public
Last active

little function to make a bib key based on data gleaned from rss feed data

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
# >> 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.