Module: Bluecap::Keys
- Defined in:
- lib/bluecap/keys.rb
Class Method Summary collapse
-
.clean(str) ⇒ Object
Returns a cleaned version of a string for use in a Redis key.
- .cohort(report_id, cohort_id) ⇒ Object
- .engagement(report_id, cohort_id, date) ⇒ Object
-
.event(name, date) ⇒ Object
Returns a key used to store the events for a day.
Class Method Details
.clean(str) ⇒ Object
Returns a cleaned version of a string for use in a Redis key. Strips, downcases, then treats any remaining characters like word separators as periods.
str - The String to be cleaned.
Examples
clean('Country')
# => "country"
clean('Logged In')
# => "logged.in"
Returns the new String.
19 20 21 |
# File 'lib/bluecap/keys.rb', line 19 def self.clean(str) str.strip.downcase.gsub(/[^a-z0-9]/, '.') end |
.cohort(report_id, cohort_id) ⇒ Object
35 36 37 |
# File 'lib/bluecap/keys.rb', line 35 def self.cohort(report_id, cohort_id) "reports:cohort:#{report_id}:#{cohort_id}" end |
.engagement(report_id, cohort_id, date) ⇒ Object
39 40 41 |
# File 'lib/bluecap/keys.rb', line 39 def self.engagement(report_id, cohort_id, date) "reports:e:#{report_id}:#{cohort_id}:#{date}" end |