https://github.com/danielpclark/stopwatch_cr
A stopwatch timer for Crystal
https://github.com/danielpclark/stopwatch_cr
crystal stopwatch timer
Last synced: 3 months ago
JSON representation
A stopwatch timer for Crystal
- Host: GitHub
- URL: https://github.com/danielpclark/stopwatch_cr
- Owner: danielpclark
- License: mit
- Created: 2017-04-11T17:53:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-11T17:57:12.000Z (almost 9 years ago)
- Last Synced: 2025-01-20T12:46:23.441Z (about 1 year ago)
- Topics: crystal, stopwatch, timer
- Language: Crystal
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://travis-ci.org/danielpclark/stopwatch_cr)
[](https://saythanks.io/to/danielpclark)
# Stopwatch
_Ported from Ruby._
A stopwatch timer where you hit `mark` to start the timer and continue to hit `mark` to mark times.
## Installation
Add this line to your application's shard.yml:
```crystal
dependencies:
stopwatch:
github: danielpclark/stopwatch_cr
branch: master
```
## Usage
```ruby
require 'stopwatch'
watch = Stopwatch::Timer.new
watch.mark
# => 2017-02-24 18:03:43 -0500
watch.time?
# => false
watch.mark
# => [44.973787791]
watch.time?
# => true
watch.mark
# => [44.973787791, 6.39862104]
watch.mark
# => [44.973787791, 6.39862104, 4.238468485]
watch.h # human total time
# => "00:00:55"
watch.ha # human average
# => "18.54 second average"
watch.times
# => [44.973787791, 6.39862104, 4.238468485]
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/danielpclark/stopwatch_cr.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).