https://github.com/styd/sleep2
Ruby sleep 😴 with extra magical stuff.
https://github.com/styd/sleep2
gem ruby sleep
Last synced: about 21 hours ago
JSON representation
Ruby sleep 😴 with extra magical stuff.
- Host: GitHub
- URL: https://github.com/styd/sleep2
- Owner: styd
- License: mit
- Created: 2017-03-04T05:17:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-25T07:33:35.000Z (over 7 years ago)
- Last Synced: 2024-10-11T17:04:23.548Z (8 months ago)
- Topics: gem, ruby, sleep
- Language: Ruby
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Sleep2 [](https://travis-ci.org/styd/sleep2)
Ruby sleep with extra magical stuff. These extra stuff will be useful when you
are developing an algorithm with some kind of delay patterns such as in
animation.## Installation
Add this line to your application's Gemfile:
```ruby
gem 'sleep2'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install sleep2
## Usage
Don't forget to `require 'sleep2'` first.
### Do math with sleep.
```ruby
>> sleep = Sleep2[2] # no sleep when instantiating
#=> #
>> sleep # sleeps for 2 seconds
#=> #
>> delay = sleep * 2 # instantiate new sleep object (therefore no sleeping yet)
#=> #
>> delay # sleeps twice longer than sleep
#=> #
```### Compare sleep with integer (in seconds) or another of its type
```ruby
>> sleep if sleep > 3 # not sleeping at all since sleep duration is 2 seconds
#=> nil
>> delay = Sleep2[3] # no sleep when instantiating
#=> #
>> delay > sleep ? delay : sleep # sleeps for 3 seconds
#=> #
```### Change current instance duration
```ruby
>> freeze = Sleep2[3] # no sleep when instantiating
#=> #
>> freeze[4] # no sleep when changing duration
#=> 4.0
>> freeze # sleeps for 4 seconds
#=> #
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/styd/sleep2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).