time-duration 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +40 -7
- data/lib/time_duration/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0442605737d2771dfc2851b423314004a3ff36c90ca333d3a853b65406383312
|
4
|
+
data.tar.gz: aa2393be39bea4695c7a58c0d36b336b622484faa592f077af1cd0e5b97ee5f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a62509caf01a6cf2ed7ef996d3b3bbb19038cfd2da849e7657aa788251def6fd3db46b8faa8e769482b75305f7f85a51787fa244c73981f2b9c8086117151ef
|
7
|
+
data.tar.gz: b151a4f20375f6067bec4dea7265db305d9a198d3c9a8d09a0568a8a398f1dca80b4a49ac02c5cf416f1f35225bb40035b6242b4887eea870195229f56aa5429
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
# TimeDuration
|
2
2
|
|
3
|
-
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.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
10
6
|
|
11
7
|
```ruby
|
12
|
-
gem '
|
8
|
+
gem 'time-duration'
|
13
9
|
```
|
14
10
|
|
15
11
|
And then execute:
|
@@ -18,11 +14,48 @@ And then execute:
|
|
18
14
|
|
19
15
|
Or install it yourself as:
|
20
16
|
|
21
|
-
$ gem install
|
17
|
+
$ gem install time-duration
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
21
|
+
|
22
|
+
|
23
|
+
### Parser
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
duration = TimeDuration.parse('1:10')
|
27
|
+
duration.to_s # => "1:10"
|
28
|
+
|
29
|
+
duration = TimeDuration.parse('1:70')
|
30
|
+
duration.to_s # => "2:10"
|
31
|
+
```
|
32
|
+
|
33
|
+
### Initializer
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
TimeDuration::Duration.new # => 0:00
|
37
|
+
TimeDuration::Duration.new(minutes: 10) # => 0:10
|
38
|
+
TimeDuration::Duration.new(hours: 1) # => 1:00
|
39
|
+
TimeDuration::Duration.new(hours: 1, minutes: 10) # => 1:10
|
40
|
+
```
|
41
|
+
|
42
|
+
### Operations
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
duration = TimeDuration.parse('0:40') + TimeDuration.parse('0:30')
|
46
|
+
duration.to_s # => "1:10"
|
47
|
+
|
48
|
+
duration = TimeDuration.parse('0:40') - TimeDuration.parse('0:30')
|
49
|
+
duration.to_s # => "0:10"
|
50
|
+
```
|
51
|
+
|
52
|
+
### Comparisons
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
TimeDuration.parse('0:40') > TimeDuration.parse('0:30') # => true
|
56
|
+
|
57
|
+
TimeDuration.parse('0:60') == TimeDuration.parse('1:00') # => true
|
58
|
+
```
|
26
59
|
|
27
60
|
## Development
|
28
61
|
|