time_math2 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -75
  3. data/lib/time_math/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 006dfa63a22116ad083fd98e2aca4390734bce26
4
- data.tar.gz: 028d5e1ca0a36f80840b95aadb675f60497385f5
3
+ metadata.gz: 76771d4aa5435a2100af858a4bd4851ef81d35c9
4
+ data.tar.gz: 23abf05b1c0b3dd19a6552619cda98e360b73840
5
5
  SHA512:
6
- metadata.gz: 261cbba1b37663d18b456edfb0f0ea7a18dbd7c78c72d4c77d6d20feb664a90f4ca2baaffcaf7493a04181cf37c40a4c3480e2493dd767d4dece3dcdf0271e37
7
- data.tar.gz: 2d9beccf3cd5e3a3b4f7a35366ec20576dc770c7570768cc6784b8cfb0bcc139df713ac88ac764ba2eb2eb44b6c4aa070d6c3b1e20626bb5c58540a38eff991b
6
+ metadata.gz: a314061838072dac1c4bec199a7a1128f74732a3a0cc041996674e1b6d91a35b53cdd7f7800a9b187108afd73d03027e4e6776c9c5b53f3393df06b2f13d0231
7
+ data.tar.gz: 192e2f2f194d52dc4d39868ccae10d83bab53350b63177725c3677c2e607574463420d62eab0c6151741747a1a0fe44de408cc103713319d3de607907ef8bf9e
data/README.md CHANGED
@@ -208,81 +208,6 @@ it means:
208
208
  it is preserved by TimeMath (but be careful about jumping around DST,
209
209
  offset would not change).
210
210
 
211
-
212
- ## Time series generation: "laces"
213
-
214
- I'm a real fan of funny names in gems. Here we have time **boots** for working
215
- with time **steps**. So, something continuous will be called **lace**.
216
-
217
- I hope, next examples are pretty self-explanatory.
218
-
219
- ```ruby
220
- from = Time.parse('2015-03-05 10:08')
221
- to = Time.parse('2015-03-09 11:07')
222
-
223
- lace = TimeBoots.month.lace(from, to)
224
- # => #<TimeBoots::Lace(2015-03-05 10:08:00 +0200 - 2015-03-09 11:07:00 +0200)>
225
-
226
- # or
227
- TimeBoots.lace(:month, from, to)
228
- # => #<TimeBoots::Lace(2015-03-05 10:08:00 +0200 - 2015-03-09 11:07:00 +0200)>
229
-
230
- lace.pull
231
- # => [2015-03-05 10:08:00 +0200,
232
- # 2015-03-06 10:08:00 +0200,
233
- # 2015-03-07 10:08:00 +0200,
234
- # 2015-03-08 10:08:00 +0200,
235
- # 2015-03-09 10:08:00 +0200]
236
- ```
237
-
238
- So, we have just a series of times, each day, from `from` until `to`.
239
- Note, there is a same time of the day (10:08), as it was in `from`.
240
-
241
- The `pull` method has an optional argument, when it is `true`, the
242
- method returns `floor`-ed times (e.g. midnights for daily lace):
243
-
244
- ```ruby
245
- lace.pull(true)
246
- # => [2015-03-05 10:08:00 +0200,
247
- # 2015-03-06 00:00:00 +0200,
248
- # 2015-03-07 00:00:00 +0200,
249
- # 2015-03-08 00:00:00 +0200,
250
- # 2015-03-09 00:00:00 +0200]
251
- ```
252
-
253
- Note the first value still at 10:08: we don't want to go before `from`.
254
- Lace also can "expand" your period for you (`floor` the beginning and
255
- `ceil` the end):
256
-
257
- ```ruby
258
- lace.expand
259
- # => #<TimeBoots::Lace(2015-03-05 00:00:00 +0200-2015-03-10 00:00:00 +0200)>
260
-
261
- # or
262
- lace.expand!
263
-
264
- # or start with expanded:
265
- TimeBoots.month.lace(from, to, expanded: true)
266
- ```
267
-
268
- Another useful lace's functionality is generating periods.
269
- It can be useful for filtering daily data from database, for example:
270
-
271
- ```ruby
272
- lace.pull_ranges
273
- # => [2015-03-05 10:08:00 +0200...2015-03-06 10:08:00 +0200,
274
- # 2015-03-06 10:08:00 +0200...2015-03-07 10:08:00 +0200,
275
- # 2015-03-07 10:08:00 +0200...2015-03-08 10:08:00 +0200,
276
- # 2015-03-08 10:08:00 +0200...2015-03-09 10:08:00 +0200,
277
- # 2015-03-09 10:08:00 +0200...2015-03-09 11:07:00 +0200]
278
-
279
- # Now, you can do something like:
280
-
281
- lace.pull_ranges.map{|range| dataset.where(timestamp: range).count}
282
- # ...and have your daily stats with one line of code
283
-
284
- ```
285
-
286
211
  ## Got it, what else?
287
212
 
288
213
  TimeMath also play well when included into other classes or modules:
@@ -1,4 +1,4 @@
1
1
  module TimeMath
2
2
  # @private
3
- VERSION = '0.0.3'.freeze
3
+ VERSION = '0.0.4'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_math2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev