Module: RedisOrm::Utils
- Included in:
- Base
- Defined in:
- lib/redis_orm/utils.rb
Instance Method Summary collapse
Instance Method Details
#calculate_key_for_zset(string) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/redis_orm/utils.rb', line 3 def calculate_key_for_zset(string) return 0.0 if string.nil? sum = "" string.codepoints.each do |codepoint| sum += ("%05i" % codepoint.to_s) # 5 because 65536 => 2 bytes UTF-8 end "0.#{sum}".to_f end |