ice_cube 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ice_cube/schedule.rb +27 -0
- data/lib/ice_cube/version.rb +1 -1
- metadata +3 -3
data/lib/ice_cube/schedule.rb
CHANGED
@@ -43,6 +43,33 @@ module IceCube
|
|
43
43
|
from_hash(YAML::load(str))
|
44
44
|
end
|
45
45
|
|
46
|
+
TIME_FORMAT = '%B %e, %Y'
|
47
|
+
SEPARATOR = ' / '
|
48
|
+
|
49
|
+
# use with caution
|
50
|
+
# incomplete and not entirely tested - no time representation in dates
|
51
|
+
# there's a lot that can happen here
|
52
|
+
def to_s
|
53
|
+
representation = ''
|
54
|
+
inc_dates = @rdates - @exdates
|
55
|
+
if inc_dates && !inc_dates.empty?
|
56
|
+
representation << inc_dates.map { |d| d.strftime(TIME_FORMAT) }.join(SEPARATOR)
|
57
|
+
end
|
58
|
+
if @rrule_occurrence_heads && !@rrule_occurrence_heads.empty?
|
59
|
+
representation << SEPARATOR unless representation.empty?
|
60
|
+
representation << @rrule_occurrence_heads.map{ |r| r.rule.to_s }.join(SEPARATOR)
|
61
|
+
end
|
62
|
+
if @exrule_occurrence_heads && !@exrule_occurrence_heads.empty?
|
63
|
+
representation << SEPARATOR unless representation.empty?
|
64
|
+
representation << @exrule_occurrence_heads.map { |r| 'not ' << r.to_s }.join(SEPARATOR)
|
65
|
+
end
|
66
|
+
if @exdates && !@exdates.empty?
|
67
|
+
representation << SEPARATOR unless representation.empty?
|
68
|
+
representation << @exdates.map { |d| 'not on ' << d.strftime(TIME_FORMAT) }.join(SEPARATOR)
|
69
|
+
end
|
70
|
+
representation
|
71
|
+
end
|
72
|
+
|
46
73
|
# Determine whether a given time adheres to the ruleset of this schedule.
|
47
74
|
def occurs_at?(date)
|
48
75
|
dates = occurrences(date)
|
data/lib/ice_cube/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Crepezzi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-27 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|