GoDuration Ruby Gem - Parses and generates Go's time.Duration format
Ruby Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
test
.gitignore
.travis.yml
CHANGELOG.md
Gemfile
README.md
Rakefile
go_duration.gemspec

README.md

GoDuration for Ruby

Gem Version Build Status

Installation

Add this line to your application's Gemfile:

gem 'go_duration'

And then execute:

$ bundle

Or install it yourself as:

$ gem install go_duration

Usage

Parsing

require 'go_duration'

GoDuration.parse("2m30s") # => 150

Generating

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"