Module: Minuteman::BitOperations
- Defined in:
- lib/minuteman/bit_operations.rb,
lib/minuteman/bit_operations/data.rb,
lib/minuteman/bit_operations/plain.rb,
lib/minuteman/bit_operations/result.rb,
lib/minuteman/bit_operations/operation.rb,
lib/minuteman/bit_operations/with_data.rb
Defined Under Namespace
Classes: Data, Operation, Plain, Result, WithData
Instance Method Summary collapse
-
#&(timespan) ⇒ Object
Public: Calculates the AND against another timespan.
-
#-(timespan) ⇒ Object
Public: Calculates the substract of one set to another.
-
#-@ ⇒ Object
(also: #~@)
Public: Calculates the NOT of the current key.
-
#^(timespan) ⇒ Object
Public: Calculates the XOR against another timespan.
-
#include?(*ids) ⇒ Boolean
Public: Checks for the existance of ids on a given set.
-
#length ⇒ Object
Public: Cheks for the amount of ids stored on the current key.
-
#reset ⇒ Object
Public: Resets the current key.
-
#|(timespan) ⇒ Object
(also: #+)
Public: Calculates the OR against another timespan.
Instance Method Details
#&(timespan) ⇒ Object
Public: Calculates the AND against another timespan
timespan: Another BitOperations enabled class or an Array
62 63 64 |
# File 'lib/minuteman/bit_operations.rb', line 62 def &(timespan) operation("AND", timespan) end |
#-(timespan) ⇒ Object
Public: Calculates the substract of one set to another
timespan: Another BitOperations enabled class
37 38 39 |
# File 'lib/minuteman/bit_operations.rb', line 37 def -(timespan) operation("MINUS", timespan) end |
#-@ ⇒ Object Also known as: ~@
Public: Calculates the NOT of the current key
28 29 30 |
# File 'lib/minuteman/bit_operations.rb', line 28 def -@ operation("NOT", key) end |
#^(timespan) ⇒ Object
Public: Calculates the XOR against another timespan
timespan: Another BitOperations enabled class
45 46 47 |
# File 'lib/minuteman/bit_operations.rb', line 45 def ^(timespan) operation("XOR", timespan) end |
#include?(*ids) ⇒ Boolean
Public: Checks for the existance of ids on a given set
ids - Array of ids
9 10 11 12 |
# File 'lib/minuteman/bit_operations.rb', line 9 def include?(*ids) result = ids.map { |id| getbit(id) } result.size == 1 ? result.first : result end |
#length ⇒ Object
Public: Cheks for the amount of ids stored on the current key
22 23 24 |
# File 'lib/minuteman/bit_operations.rb', line 22 def length redis.bitcount(key) end |
#reset ⇒ Object
Public: Resets the current key
16 17 18 |
# File 'lib/minuteman/bit_operations.rb', line 16 def reset redis.rem(key) end |
#|(timespan) ⇒ Object Also known as: +
Public: Calculates the OR against another timespan
timespan: Another BitOperations enabled class or an Array
53 54 55 |
# File 'lib/minuteman/bit_operations.rb', line 53 def |(timespan) operation("OR", timespan) end |