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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4a6d9b7c6aa42b4be3fc512c9666e69ada37c70
4
- data.tar.gz: 0e107036ca4831c4d3fc65337bc5d0e464806c94
3
+ metadata.gz: 386ce8c5df4891c9bb704bed44ba5075477edfba
4
+ data.tar.gz: fbc7491186230799388a4be91704f0a4d5ad2262
5
5
  SHA512:
6
- metadata.gz: fdc76e2d6d9bb72a29c8b935749556c165884ebb7047807449a8510a53945ca3b96b9aeaeda97eb81aa2dae422e3dc193863a3df5169910130053a0729d8b05d
7
- data.tar.gz: 01e779cc198833a4d67ac8b8f8fbbfc15a1b69d14663f9edfeb9926575d20c49ecad33366204d20b046163d3e0cfcc61e1b4b49c5dc686dd6112524ab5d776b0
6
+ metadata.gz: 7f839939978f366c94bb579b6693a2db753cd6a5ba4db828899e2cbc9748b4125072d4b492a39d29a3b7f567b2fec56222ac9af31ba68c4fc56e1fbdb9d4a377
7
+ data.tar.gz: 6befff2858d6e004f289426bd7ae6659cf11df82509f89e4442feb7e498cd3514702655fc2323c5a281b5b7630b05186c1d4eb5a7681bcec0d2267c6815c80ed
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # TimeSeq
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/time_seq`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/time_seq.
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
+ ```
@@ -1,3 +1,3 @@
1
1
  class TimeSeq
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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).instance_eval do
11
- extract opt
12
- build_enum
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
- break if to and time_point > to
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 (infinite) time sequence }
13
- #spec.description = %q{TODO: Write a longer description or delete this line.}
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.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 (infinite) time sequence
110
+ summary: generate a time sequence, which may be infinite
109
111
  test_files: []