schedulicon 0.0.1 → 0.0.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/schedulicon/schedule.rb +10 -11
- data/lib/schedulicon/version.rb +1 -1
- metadata +2 -2
data/lib/schedulicon/schedule.rb
CHANGED
@@ -10,10 +10,10 @@ module Schedulicon
|
|
10
10
|
attr_accessor :frequency, :day_of_week, :start_at, :end_on
|
11
11
|
|
12
12
|
def initialize(attrs={})
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
13
|
+
@start_at = Time.xmlschema(attrs['start_at']).localtime if attrs['start_at']
|
14
|
+
@end_on = Time.xmlschema(attrs['end_on']).localtime if attrs['end_on']
|
15
|
+
@day_of_week = attrs['day_of_week'] ? attrs['day_of_week'].to_i : Schedulicon::MONDAY
|
16
|
+
@frequency = attrs['frequency'] ? attrs['frequency'].to_sym : :every
|
17
17
|
end
|
18
18
|
|
19
19
|
# Public: Hash of attributes that can be used to deserialise item from
|
@@ -21,22 +21,21 @@ module Schedulicon
|
|
21
21
|
def to_hash
|
22
22
|
hash = {
|
23
23
|
'frequency' => frequency,
|
24
|
-
'start_at' => start_at.xmlschema,
|
25
24
|
'day_of_week' => day_of_week
|
26
25
|
}
|
26
|
+
hash['start_at'] = start_at.xmlschema if start_at
|
27
27
|
hash['end_on'] = end_on.xmlschema if end_on
|
28
28
|
hash
|
29
29
|
end
|
30
30
|
|
31
|
+
def attributes
|
32
|
+
to_hash
|
33
|
+
end
|
34
|
+
|
31
35
|
# Public: load schedule from the hash
|
32
36
|
#
|
33
37
|
def self.load(attrs)
|
34
|
-
|
35
|
-
schedule.start_at = Time.xmlschema(attrs['start_at']).localtime
|
36
|
-
schedule.end_on = Time.xmlschema(attrs['end_on']).localtime if attrs['end_on']
|
37
|
-
schedule.day_of_week = attrs['day_of_week'].to_i
|
38
|
-
schedule.frequency = attrs['frequency'].to_sym
|
39
|
-
schedule
|
38
|
+
Schedule.new(attrs)
|
40
39
|
end
|
41
40
|
|
42
41
|
# Public: generates the expression required to generate the schedule dates
|
data/lib/schedulicon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schedulicon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Gem for recurring events
|
15
15
|
email: adam.bird@gmail.com
|