Class: Minuteman::BitOperations::Plain

Inherits:
Struct
  • Object
show all
Includes:
KeysMethods
Defined in:
lib/minuteman/bit_operations/plain.rb

Overview

Public: The class to handle operations with others timespans

redis:      The Redis connection
type:       The operation type
timespan:   The timespan to be permuted
source_key: The original key to do the operation

Constant Summary

Constants included from KeysMethods

KeysMethods::BIT_OPERATION_PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#redisObject

Returns the value of attribute redis

Returns:

  • (Object)

    the current value of redis



13
14
15
# File 'lib/minuteman/bit_operations/plain.rb', line 13

def redis
  @redis
end

#source_keyObject

Returns the value of attribute source_key

Returns:

  • (Object)

    the current value of source_key



13
14
15
# File 'lib/minuteman/bit_operations/plain.rb', line 13

def source_key
  @source_key
end

#timespanObject

Returns the value of attribute timespan

Returns:

  • (Object)

    the current value of timespan



13
14
15
# File 'lib/minuteman/bit_operations/plain.rb', line 13

def timespan
  @timespan
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



13
14
15
# File 'lib/minuteman/bit_operations/plain.rb', line 13

def type
  @type
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/minuteman/bit_operations/plain.rb', line 16

def call
  events = if source_key == timespan
             Array(source_key)
           else
             [source_key, timespan.key]
           end

  key = destination_key(type, events)
  redis.bitop(type, key, events)
  Result.new(redis, key)
end