time_seq 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +29 -15
- data/lib/time_seq/version.rb +1 -1
- data/lib/time_seq.rb +7 -4
- data/time_seq.gemspec +3 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 386ce8c5df4891c9bb704bed44ba5075477edfba
|
4
|
+
data.tar.gz: fbc7491186230799388a4be91704f0a4d5ad2262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f839939978f366c94bb579b6693a2db753cd6a5ba4db828899e2cbc9748b4125072d4b492a39d29a3b7f567b2fec56222ac9af31ba68c4fc56e1fbdb9d4a377
|
7
|
+
data.tar.gz: 6befff2858d6e004f289426bd7ae6659cf11df82509f89e4442feb7e498cd3514702655fc2323c5a281b5b7630b05186c1d4eb5a7681bcec0d2267c6815c80ed
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# TimeSeq
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A well-understood interface to build lazy enumerator for iterating time points
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,15 +20,31 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
```ruby
|
24
|
+
require 'time_seq'
|
25
|
+
|
26
|
+
seq = TimeSeq.new from: Time.gm(2016, 'nov'), step: 1.hour, to: Time.gm(2016, 'nov', 1, 5)
|
27
|
+
=> #<TimeSeq:19952030 @from=2016-11-01 00:00:00 UTC, @step=1 hour, @to=2016-11-01 05:00:00 UTC>
|
28
|
+
seq.to_a
|
29
|
+
=> [2016-11-01 00:00:00 UTC,
|
30
|
+
2016-11-01 01:00:00 UTC,
|
31
|
+
2016-11-01 02:00:00 UTC,
|
32
|
+
2016-11-01 03:00:00 UTC,
|
33
|
+
2016-11-01 04:00:00 UTC,
|
34
|
+
2016-11-01 05:00:00 UTC]
|
35
|
+
|
36
|
+
# Ending is not required. It can do whatever a Enumerator::Lazy can do
|
37
|
+
infinite_seq = TimeSeq.new from: Time.gm(2016, 'dec', 1, 7, 30), step: 1.day
|
38
|
+
=> #<TimeSeq:19403900 @from=2016-12-01 07:30:00 UTC, @step=1 day>
|
39
|
+
infinite_seq.first(10)
|
40
|
+
=> [2016-12-01 07:30:00 UTC,
|
41
|
+
2016-12-02 07:30:00 UTC,
|
42
|
+
2016-12-03 07:30:00 UTC,
|
43
|
+
2016-12-04 07:30:00 UTC,
|
44
|
+
2016-12-05 07:30:00 UTC,
|
45
|
+
2016-12-06 07:30:00 UTC,
|
46
|
+
2016-12-07 07:30:00 UTC,
|
47
|
+
2016-12-08 07:30:00 UTC,
|
48
|
+
2016-12-09 07:30:00 UTC,
|
49
|
+
2016-12-10 07:30:00 UTC]
|
50
|
+
```
|
data/lib/time_seq/version.rb
CHANGED
data/lib/time_seq.rb
CHANGED
@@ -5,11 +5,14 @@ class TimeSeq < DelegateClass(Enumerator::Lazy)
|
|
5
5
|
class << self
|
6
6
|
|
7
7
|
alias_method :init, :new
|
8
|
+
private :init
|
8
9
|
|
9
10
|
def new(opt={})
|
10
|
-
init(nil).
|
11
|
-
|
12
|
-
|
11
|
+
init(nil).tap do |time_seq|
|
12
|
+
time_seq.instance_eval do
|
13
|
+
extract opt
|
14
|
+
build_enum
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -39,7 +42,7 @@ class TimeSeq < DelegateClass(Enumerator::Lazy)
|
|
39
42
|
loop do
|
40
43
|
yielder << time_point
|
41
44
|
time_point = step.since time_point
|
42
|
-
|
45
|
+
break if to and time_point > to
|
43
46
|
end
|
44
47
|
end.lazy
|
45
48
|
__setobj__ @e
|
data/time_seq.gemspec
CHANGED
@@ -9,9 +9,10 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["ken"]
|
10
10
|
spec.email = ["block24block@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{generate a
|
13
|
-
|
12
|
+
spec.summary = %q{generate a time sequence, which may be infinite}
|
13
|
+
spec.description = %q{a well-understood interface to build lazy enumerator for iterating time points}
|
14
14
|
spec.homepage = "https://github.com/turnon/time_seq"
|
15
|
+
spec.license = "MIT"
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
18
|
spec.bindir = "exe"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_seq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
@@ -66,7 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '4.0'
|
69
|
-
description:
|
69
|
+
description: a well-understood interface to build lazy enumerator for iterating time
|
70
|
+
points
|
70
71
|
email:
|
71
72
|
- block24block@gmail.com
|
72
73
|
executables: []
|
@@ -84,7 +85,8 @@ files:
|
|
84
85
|
- lib/time_seq/version.rb
|
85
86
|
- time_seq.gemspec
|
86
87
|
homepage: https://github.com/turnon/time_seq
|
87
|
-
licenses:
|
88
|
+
licenses:
|
89
|
+
- MIT
|
88
90
|
metadata: {}
|
89
91
|
post_install_message:
|
90
92
|
rdoc_options: []
|
@@ -105,5 +107,5 @@ rubyforge_project:
|
|
105
107
|
rubygems_version: 2.6.7
|
106
108
|
signing_key:
|
107
109
|
specification_version: 4
|
108
|
-
summary: generate a
|
110
|
+
summary: generate a time sequence, which may be infinite
|
109
111
|
test_files: []
|