aromat 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/aromat/date.rb +24 -0
- data/lib/aromat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e02f365494c3634ad47652fc4699e67ab86566c5
|
4
|
+
data.tar.gz: 9a444a3d11313557d8fd3a423a6df8ec57713d86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa27ae8a211fd0ca644d885df3da8ac3f6d20782a22d54ae23a8b164ac9125f50a30ce663effad2a1026ff189d84a394484fcfc4148f913c2231b84ad93db06e
|
7
|
+
data.tar.gz: 2e3f10cc3c262162152d1afbb16de0e0bb3d15bfdc622955b02e5718ccb8dc9da0d918b8b925cd0fb2d3015876541c557f92b52dc932357111f782616a94d99a
|
data/README.md
CHANGED
@@ -123,6 +123,17 @@ Case-conversion methods are monkey-patched into the *String* class. The followin
|
|
123
123
|
# => 'foo_bar'
|
124
124
|
```
|
125
125
|
|
126
|
+
### Next / Last weekday
|
127
|
+
|
128
|
+
The *Date* class is monkey-patched to include _wnext_ and _wlast_ methods. These return the next/last occurrence of a given weekday.
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
Date.parse('2017 November 10').wnext(:friday).strftime '%Y %B %d'
|
132
|
+
# => '2017 November 17'
|
133
|
+
Date.parse('2017 November 10').wlast(:friday).strftime '%Y %B %d'
|
134
|
+
# => '2017 November 03'
|
135
|
+
```
|
136
|
+
|
126
137
|
### Module utilities
|
127
138
|
|
128
139
|
#### Get Module Name
|
data/lib/aromat/date.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Aromat
|
2
|
+
# by Eresse <eresse@eresse.net>
|
3
|
+
|
4
|
+
# Monkey-patch Date Class
|
5
|
+
class Date
|
6
|
+
|
7
|
+
# Last X:
|
8
|
+
# Get last occurence of a given weekday.
|
9
|
+
# @return [Date]
|
10
|
+
def wlast wd
|
11
|
+
d = self - 1
|
12
|
+
d = d - 1 until d.send "#{wd}?".to_sym
|
13
|
+
d
|
14
|
+
end
|
15
|
+
|
16
|
+
# Next X:
|
17
|
+
# Get next occurence of a given weekday.
|
18
|
+
# @return [Date]
|
19
|
+
def wnext wd
|
20
|
+
d = self + 1
|
21
|
+
d = d + 1 until d.send "#{wd}?".to_sym
|
22
|
+
d
|
23
|
+
end
|
24
|
+
end
|
data/lib/aromat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aromat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eresse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- aromat.gemspec
|
68
68
|
- lib/aromat.rb
|
69
69
|
- lib/aromat/case.rb
|
70
|
+
- lib/aromat/date.rb
|
70
71
|
- lib/aromat/dclone.rb
|
71
72
|
- lib/aromat/duration.rb
|
72
73
|
- lib/aromat/module.rb
|