module PopularityContest

Constants

LICENSE
NAME

Private Class Methods

content_id_from_key(key) click to toggle source
# File lib/popularity_contest.rb, line 17
def self.content_id_from_key(key)
  # 'popular:type:#{content_type}:id:12456:date:#{Date.today.strftime("%y-%m-%d")}:count'.scan(/id:(\d+)/i).flatten.first
  key.scan(/id:(\d+)/i).flatten.first.to_i
end
key(content_type, content_id, date = Date.today.strftime("%y-%m-%d")) click to toggle source

helpers

# File lib/popularity_contest.rb, line 7
def self.key(content_type, content_id, date = Date.today.strftime("%y-%m-%d"))
  key = []
  key << "popular"
  key << "type:#{content_type}"
  key << "id:#{content_id}"
  key << "date:#{date}"
  key << "hits"
  key.join(":")
end