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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48e99ccc2c99ae3803ac0040436cf4f3a94817d5
4
- data.tar.gz: bd2d806693991caf149af5170eb1274d95624545
3
+ metadata.gz: e02f365494c3634ad47652fc4699e67ab86566c5
4
+ data.tar.gz: 9a444a3d11313557d8fd3a423a6df8ec57713d86
5
5
  SHA512:
6
- metadata.gz: 874ac297a8cc5e0ed4e283d4ecfd91d98e9832a639f4b24c274e6d172feb6ad3f8875f00d078daa7ed07fd78a46c2a9eaf5ff220225c4b120024d81dcf8fa74c
7
- data.tar.gz: fee44b029e7eb120906d1b3a70e2e7a1a19e1280f5205f842fd9ca552e5f0877f16fe1f2276742f0e8cc705ce320218768c9f13ab690fabe858488a9d24576aa
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
@@ -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
@@ -5,5 +5,5 @@
5
5
  module Aromat
6
6
 
7
7
  # Version
8
- VERSION = '1.2.1'
8
+ VERSION = '1.3.0'
9
9
  end
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.2.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-05-23 00:00:00.000000000 Z
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