Skip to content

Commit e476430

Browse files
committed
doc: Update the README and basic documentation.
1 parent 05c1bf9 commit e476430

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

.markdownlint.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"MD046": false,
3+
"MD013": false
4+
}

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
# TimeRange
22

3-
TODO: Delete this and the text below, and describe your gem
4-
5-
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_range`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
Range over Time using time intervals without ActiveSupport.
64

75
## Installation
86

9-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10-
117
Install the gem and add to the application's Gemfile by executing:
128

13-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9+
bundle add time_range
1410

1511
If bundler is not being used to manage dependencies, install the gem by executing:
1612

17-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13+
gem install time_range
1814

1915
## Usage
2016

21-
TODO: Write usage instructions here
17+
Works just like Range with one important change; **you must call `#by` to set a time interval.**
18+
19+
```Ruby
20+
require 'time_range'
21+
22+
# Print the first day of each month of 2024.
23+
time_range = TimeRange
24+
.new(Time.local(2024), Time.local(2025), true)
25+
.by(months: 1)
26+
time_range.each { |time| puts time }
27+
```
2228

2329
## Development
2430

@@ -28,4 +34,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
2834

2935
## Contributing
3036

31-
Bug reports and pull requests are welcome on GitHub at https://github.com/schwern/ruby-time_range.
37+
Bug reports and pull requests are welcome on GitHub at <https://github.com/schwern/ruby-time_range>.

lib/time_range.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
require_relative 'time_range/advancer'
55
require_relative 'time_range/time'
66

7-
# Like Range, but for Time objects.
7+
# Range over Time stepping by time intervals.
8+
#
9+
# Does not require ActiveSupport.
810
#
911
# Unlike a Range, it is necessary to call #by to say how long between
1012
# each step.
@@ -30,10 +32,10 @@ def initialize(first, last, exclude_last = false) # rubocop:disable Style/Option
3032
)
3133
end
3234

33-
# The time interval to add to step through the TimeRange.
35+
# The time interval to use when iterating through the TimeRange.
3436
#
3537
# Returns the TimeRange object so you can safely chain
36-
# TimeRange.new(...).by(...)
38+
# time_range = TimeRange.new(...).by(...)
3739
#
3840
# Currently cannot be negative.
3941
#

time_range.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
88
spec.authors = ["Michael G. Schwern"]
99
spec.email = ["[email protected]"]
1010

11-
spec.summary = "Iterate using Time objects."
11+
spec.summary = "Range over Times stepping by time intervals."
1212
spec.description = "Easy iterating over various periods of time."
1313
spec.homepage = "https://github.com/schwern/ruby-time_range"
1414
spec.required_ruby_version = ">= 2.7"

0 commit comments

Comments
 (0)