Module: Redis::RecurringAtIntervals
- Defined in:
- lib/redis/recurring_at_intervals.rb,
lib/redis/recurring_at_intervals/daily.rb,
lib/redis/recurring_at_intervals/annual.rb,
lib/redis/recurring_at_intervals/hourly.rb,
lib/redis/recurring_at_intervals/weekly.rb,
lib/redis/recurring_at_intervals/monthly.rb,
lib/redis/recurring_at_intervals/minutely.rb
Defined Under Namespace
Modules: Annual, Daily, Hourly, Minutely, Monthly, Weekly
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#original_key ⇒ Object
Returns the value of attribute original_key.
10
11
12
|
# File 'lib/redis/recurring_at_intervals.rb', line 10
def original_key
@original_key
end
|
Instance Method Details
#[](date_or_time, length = nil) ⇒ Object
Also known as:
slice
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/redis/recurring_at_intervals.rb', line 12
def [](date_or_time, length = nil)
if date_or_time.is_a? Range
range(date_or_time.first, date_or_time.max)
elsif length
case length <=> 0
when 1 then range(date_or_time, next_key(date_or_time, length - 1))
when 0 then empty_value
when -1 then nil end
else
get_value_from_redis(redis_daily_field_key(date_or_time))
end
end
|
#at(date_or_time) ⇒ Object
45
46
47
|
# File 'lib/redis/recurring_at_intervals.rb', line 45
def at(date_or_time)
get_redis_object(redis_daily_field_key(date_or_time))
end
|
#current_time ⇒ Object
49
50
51
|
# File 'lib/redis/recurring_at_intervals.rb', line 49
def current_time
@current_time ||= Time.respond_to?(:current) ? Time.current : Time.now
end
|
#delete_at(date_or_time) ⇒ Object
27
28
29
|
# File 'lib/redis/recurring_at_intervals.rb', line 27
def delete_at(date_or_time)
delete_from_redis(redis_daily_field_key(date_or_time))
end
|
#initialize(key, *args) ⇒ Object
5
6
7
8
|
# File 'lib/redis/recurring_at_intervals.rb', line 5
def initialize(key, *args)
@original_key = key
super(redis_daily_field_key(current_time), *args)
end
|
#range(start_date_or_time, end_date_or_time) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/redis/recurring_at_intervals.rb', line 31
def range(start_date_or_time, end_date_or_time)
keys = []
date_or_time = start_date_or_time
loop do
break if date_or_time > end_date_or_time
keys << redis_daily_field_key(date_or_time)
date_or_time = next_key(date_or_time)
end
get_values_from_redis(keys)
end
|