mcal 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -3
- data/lib/mcal/calendar.rb +1 -2
- data/lib/mcal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8efcf8cae3164a471c5f59fa9a06407ab97aad8f
|
4
|
+
data.tar.gz: 84be2649055358de7233021f1787b325e99ad01c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17f8d582ec9d494ed1748412ba18338584aa8351fba81179ffdd3547a0fd139958fe322ca41a0b76612da34092806b0449caffd6168ce67c3ccfdf499869d52d
|
7
|
+
data.tar.gz: 028a79a7561c5b9533a453cdb3a942f80dabd434617af08aa130be6c677301ed872b5d289a7bbe4d649d7838e0812ed8837afca1925b5886bf923fbd4894e3df
|
data/README.md
CHANGED
@@ -20,11 +20,31 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
It's a really simple library. You give it a year and a month, and it'll give you back a nested array of weeks in that month. It orders the days like a standard calendar; Sunday - Saturday.
|
22
22
|
|
23
|
-
|
23
|
+
```ruby
|
24
|
+
>>> calendar = Mcal::Calendar.new(2013)
|
25
|
+
>>> calendar.monthly(4)
|
26
|
+
[[nil, 1, 2, 3, 4, 5, 6],
|
27
|
+
[ 7, 8, 9, 10, 11, 12, 13],
|
28
|
+
[ 14, 15, 16, 17, 18, 19, 20],
|
29
|
+
[ 21, 22, 23, 24, 25, 26, 27],
|
30
|
+
[ 28, 29, 30, nil, nil, nil, nil]]
|
31
|
+
```
|
32
|
+
|
33
|
+
`#monthly` also takes a block argument that receives the `Date` object in case you want to do something special:
|
24
34
|
|
25
35
|
```ruby
|
26
|
-
calendar = Calendar.new(2013)
|
27
|
-
|
36
|
+
>>> calendar = Mcal::Calendar.new(2013)
|
37
|
+
>>> holidays = [
|
38
|
+
Date.new(2013, 12, 24),
|
39
|
+
Date.new(2013, 12, 25)
|
40
|
+
]
|
41
|
+
dec = 12
|
42
|
+
>>> calendar.monthly(dec) { |d| holidays.include?(d) ? 'H' : d.mday }.must_equal [
|
43
|
+
[[ 1, 2, 3, 4, 5, 6, 7],
|
44
|
+
[ 8, 9, 10, 11, 12, 13, 14],
|
45
|
+
[ 15, 16, 17, 18, 19, 20, 21],
|
46
|
+
[ 22, 23, 'H', 'H', 26, 27, 28],
|
47
|
+
[ 29, 30, 31, nil, nil, nil, nil]
|
28
48
|
```
|
29
49
|
|
30
50
|
## Contributing
|
data/lib/mcal/calendar.rb
CHANGED
data/lib/mcal/version.rb
CHANGED