class BitOperation

Base class for bit operations (AND, OR, XOR). Please note that each bit operation creates a new key prefixed with `bitanalytics_bitop_`. These temporary keys can be deleted with `delete_temporary_bitop_keys`. You can even nest bit operations.

Example

active_2_months = @bit_analytics.bit_op_and(
    @bit_analytics.month_events('active', last_month.year, last_month.month),
    @bit_analytics.month_events('active', now.year, now.month)
)
active_2_months = @bit_analytics.bit_op_and(
    @bit_analytics.bit_op_and(
        @bit_analytics.month_events('active', last_month.year, last_month.month),
        @bit_analytics.month_events('active', now.year, now.month)
    ),
    @bit_analytics.month_events('active', now.year, now.month)
)

Public Class Methods

new(op_name, *events) click to toggle source
# File lib/bit_analytics.rb, line 251
def initialize(op_name, *events)
  @op_name = op_name
  @event_redis_keys = events.map(&:redis_key)
  @redis_key = 'bitanalytics_bitop_%s_%s' % [@op_name, @event_redis_keys.join('-')]
end

Public Instance Methods

execute() click to toggle source
# File lib/bit_analytics.rb, line 257
def execute
  @redis.bitop(@op_name, @redis_key, @event_redis_keys)
end