Sha256: 0a69c2b115cbd719a6c6b45d4ad9e5407e4000841bc2aea197d3a11bb7370431
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require "minuteman/bit_operations/plain" require "minuteman/bit_operations/with_data" class Minuteman module BitOperations # Public: Handles the operations between two timespans # # redis: The Redis connection # type: The operation type # timespan: One of the timespans to be permuted # other: The other timespan to be permuted # class Operation < Struct.new(:redis, :type, :timespan, :other) def call if type == "MINUS" && operable? return timespan ^ (timespan & other) end klass.new(redis, type, other, timespan.key).call end private # Private: returns the class to use for the operation # # timespan: The given timespan # def klass case true when other.is_a?(Array) then WithData when other.is_a?(String), operable? then Plain end end # Private: Checks if a timespan is operable # # timespan: The given timespan # def operable? other.class.ancestors.include?(BitOperations) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
minuteman-0.2.0 | lib/minuteman/bit_operations/operation.rb |
minuteman-0.2.0.pre | lib/minuteman/bit_operations/operation.rb |