https://github.com/justincampbell/go_duration_ruby
GoDuration Ruby Gem - Parses and generates Go's time.Duration format
https://github.com/justincampbell/go_duration_ruby
duration golang ruby serialization
Last synced: 7 months ago
JSON representation
GoDuration Ruby Gem - Parses and generates Go's time.Duration format
- Host: GitHub
- URL: https://github.com/justincampbell/go_duration_ruby
- Owner: justincampbell
- Created: 2017-05-19T20:34:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-19T21:46:33.000Z (about 9 years ago)
- Last Synced: 2024-08-09T15:01:42.127Z (almost 2 years ago)
- Topics: duration, golang, ruby, serialization
- Language: Ruby
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# GoDuration for Ruby
[](https://badge.fury.io/rb/go_duration)
[](https://travis-ci.org/justincampbell/go_duration_ruby)
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'go_duration'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install go_duration
## Usage
### Parsing
```rb
require 'go_duration'
GoDuration.parse("2m30s") # => 150
```
### Generating
```rb
require 'go_duration'
GoDuration.generate(150) # => "2m30s"
require 'go_duration/core_ext'
150.to_go_duration # => "2m30"
require 'active_support/core_ext'
(2.hours + 45.minutes).to_go_duration # => "2h45m"
```