EdvardM-recurrence 0.1.15 → 0.1.16

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.
Files changed (2) hide show
  1. data/README.textile +77 -0
  2. metadata +3 -3
@@ -0,0 +1,77 @@
1
+ h2. Recurrence
2
+
3
+ h3. Overview
4
+
5
+ Recurrence provides a simple class for handling recurring, time-associated objects. The goal is to create a general-purpose,
6
+ loosely coupled class library to provide common functionality for events occurring at predetermined intervals.
7
+
8
+ Short example:
9
+
10
+ require 'recurrence'
11
+
12
+ first_of_june = [2008, 6, 1]
13
+ r = Recurrence.new(first_of_june, :every_other => :week, :until => '2010-06-01')
14
+
15
+ my_cal = MyCalendar.new_default
16
+ my_cal.each_day { |date|
17
+ time = Time.parse(date) # assuming date can be parsed with Time.parse
18
+ puts 'Yay! today is the day!' if r.recurs_on?(time)
19
+ }
20
+
21
+ h3. Set-like operations
22
+
23
+ Real power of Recurrence lies in it's support for set-like operations +join+, +intersect+, +diff+ and +complement+. For example,
24
+ given the start date of 2008-06-01, recur something every thursday and friday:
25
+
26
+ require 'recurrence'
27
+
28
+ start_date = '2008-06-01'
29
+ r1 = Recurrence.new(start_date, :every => :thursday)
30
+ r2 = Recurrence.new(start_date, :every => :friday)
31
+ r = r1.join(r2)
32
+
33
+ Another example, a tad contrived perhaps:
34
+
35
+ #Recur something every friday, except if it is last friday of the month:
36
+
37
+ dow = :friday
38
+ r1 = Recurrence.new(:epoch, :every => dow)
39
+ r2 = Recurrence.new(:epoch, :every_last => dow, :of => :month)
40
+
41
+ r = r1.diff(r2)
42
+
43
+ Nested set-like operations are also possible. So, for arbitrary recurrences a and b and any time t, the following should always apply:
44
+
45
+ r1 = (a.join(b)).complement
46
+ r2 = (a.complement).intersect(b.complement)
47
+
48
+ r1.recurs_on?(t) == r2.recurs_on?(t) # De Morgan's law - complement of a union is the same as intersection of the complements
49
+
50
+ See RecurrenceBase::SetOperations for more.
51
+
52
+ h3. Installation
53
+
54
+ Enter
55
+
56
+ rake gem
57
+
58
+ on the command line in the same directory as this README file, it should produce the gem under the pkg directory.
59
+ Then you should be able to say
60
+
61
+ sudo gem install pkg/recurrence*.gem
62
+
63
+ to install the gem to your local system.
64
+
65
+ Alternatively, you can pull gem from the github:
66
+
67
+ # Add github gems to your gem sources (you can skip this if you have done so already)
68
+
69
+ sudo gem sources -a http://gems.github.com
70
+ # sudo gem install EdvardM-recurrence
71
+
72
+ KTHXBAI
73
+
74
+ h3. License
75
+
76
+ MIT (see MIT-LICENSE)
77
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: EdvardM-recurrence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edvard Majakari
@@ -20,9 +20,9 @@ executables: []
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - README
23
+ - README.textile
24
24
  files:
25
- - README
25
+ - README.textile
26
26
  has_rdoc: "true"
27
27
  homepage:
28
28
  post_install_message: