README.md in time-duration-0.1.0 vs README.md in time-duration-0.1.1

- old
+ new

@@ -1,29 +1,62 @@ # TimeDuration -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_duration`. To experiment with that code, run `bin/console` for an interactive prompt. - -TODO: Delete this and the text above, and describe your gem - ## Installation Add this line to your application's Gemfile: ```ruby -gem 'time_duration' +gem 'time-duration' ``` And then execute: $ bundle Or install it yourself as: - $ gem install time_duration + $ gem install time-duration ## Usage -TODO: Write usage instructions here + + +### Parser + +```ruby +duration = TimeDuration.parse('1:10') +duration.to_s # => "1:10" + +duration = TimeDuration.parse('1:70') +duration.to_s # => "2:10" +``` + +### Initializer + +```ruby +TimeDuration::Duration.new # => 0:00 +TimeDuration::Duration.new(minutes: 10) # => 0:10 +TimeDuration::Duration.new(hours: 1) # => 1:00 +TimeDuration::Duration.new(hours: 1, minutes: 10) # => 1:10 +``` + +### Operations + +```ruby +duration = TimeDuration.parse('0:40') + TimeDuration.parse('0:30') +duration.to_s # => "1:10" + +duration = TimeDuration.parse('0:40') - TimeDuration.parse('0:30') +duration.to_s # => "0:10" +``` + +### Comparisons + +```ruby +TimeDuration.parse('0:40') > TimeDuration.parse('0:30') # => true + +TimeDuration.parse('0:60') == TimeDuration.parse('1:00') # => true +``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.