duration.rb 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +46 -16
  3. data/lib/Duration/VERSION.rb +1 -1
  4. metadata +2 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 331e01e9221cf04af8f902433555ee8b71a4cfe254df6393cead5e75b3c63942
4
- data.tar.gz: 37efa6a608b7b2c301ce42eb2401618c96eb038cf874573eb693b79da88e3d18
3
+ metadata.gz: 38154d0b4ffc022c025fb1ab7e8cc138bd3de4c9fdf9647470833c67b6ed654e
4
+ data.tar.gz: b6757bd78e018cb8d28df7c1e06c90916ac848e5b0720ef8d2d62c04f9224a44
5
5
  SHA512:
6
- metadata.gz: 180f1e84cd3348f726e206f86113b236ef4635962d5f54b0b4a83e6e4df58718b6b6202f201d5ab913c5561e77c34dc2879943cb34645334a01b52d314a2ffae
7
- data.tar.gz: 66ab65f1add027207892c16dc71b4c45c0d9e26bbca579e683612286a240c51b125cd7a4d7bda776877bc150e813059dcbd1935d60b64dbbf828fae48557e467
6
+ metadata.gz: 6ee50579a2597c396281ce00aba23b6b558f853309d7fe976dd164a0dbfb992f5f4a574d54764f114e5b89b078cd80c2c1db89f4dafd07e036eb5692cc9309df
7
+ data.tar.gz: cd7cc3d6a4d011d2dd50d46f1841fd04e6c004d58e8fff8206d172bdb19b5141da54f66f681e9038a69f99a25e71bb4de99e4a6deb41a2749e7e6d68dd114be2
data/README.md CHANGED
@@ -16,7 +16,7 @@ And then execute:
16
16
  $ bundle
17
17
  ```
18
18
 
19
- Or install it yourself as:
19
+ Or install directly:
20
20
  ```shell
21
21
  $ gem install duration.rb
22
22
  ```
@@ -26,30 +26,39 @@ $ gem install duration.rb
26
26
  ### Basic Duration Creation
27
27
  ```ruby
28
28
  # Create durations using convenience methods
29
- 1.second # => #<Seconds: 1>
30
- 30.minutes # => #<Minutes: 30>
31
- 2.hours # => #<Hours: 2>
32
- 7.days # => #<Days: 7>
29
+ 200.milliseconds # => #<Milliseconds: @milliseconds=200>
30
+ 1.second # => #<Seconds: @seconds=1>
31
+ 30.minutes # => #<Minutes: @minutes=30>
32
+ 2.hours # => #<Hours: @hours=2>
33
+ 7.days # => #<Days: @days=7>
34
+ 4.weeks # => #<Weeks: @weeks=4>
35
+ 6.months # => #<Months: @months=6>
33
36
  ```
34
37
 
35
38
  ### Conversions
36
39
  ```ruby
37
40
  # Convert to integers
38
- 1.second.to_i # => 1
39
- 30.minutes.to_i # => 30
40
- 2.hours.to_i # => 2
41
- 7.days.to_i # => 7
41
+ 200.milliseconds.to_i # => 200
42
+ 1.second.to_i # => 1
43
+ 30.minutes.to_i # => 30
44
+ 2.hours.to_i # => 2
45
+ 7.days.to_i # => 7
46
+ 4.weeks.to_i # => 4
47
+ 6.months.to_i # => 6
42
48
 
43
49
  # Convert to floats
44
- 1.second.to_f # => 1.0
45
- 30.minutes.to_f # => 30.0
46
- 2.hours.to_f # => 2.0
47
- 7.days.to_f # => 7.0
50
+ 200.milliseconds.to_f # => 200.0
51
+ 1.second.to_f # => 1.0
52
+ 30.minutes.to_f # => 30.0
53
+ 2.hours.to_f # => 2.0
54
+ 7.days.to_f # => 7.0
55
+ 4.weeks.to_f # => 4.0
56
+ 6.months.to_f # => 6.0
48
57
 
49
58
  # Convert between units
50
- 90.minutes.to_hours # => <Hours: 1.5>
51
- 1.5.hours.to_minutes # => <Minutes: 90>
52
- 1.day.to_seconds # => <Seconds: 86400>
59
+ 90.minutes.to_hours # => #<Hours: @hours=1.5>
60
+ 1.5.hours.to_minutes # => #<Minutes: @minutes=90>
61
+ 1.day.to_seconds # => #<Seconds: @seconds=86400>
53
62
 
54
63
  # Chain conversions
55
64
  90.minutes.to_hours.to_f # => 1.5
@@ -57,6 +66,27 @@ $ gem install duration.rb
57
66
  1.day.to_seconds.to_i # => 86400
58
67
  ```
59
68
 
69
+ ### Time Calculations
70
+ ```ruby
71
+ # The past
72
+ 1.millisecond.ago # => #<Time:> (now - 1.millisecond.to_seconds.to_f)
73
+ 2.seconds.ago # => #<Time:> (now - 2.seconds.to_seconds.to_f)
74
+ 3.minutes.ago # => #<Time:> (now - 3.minutes.to_seconds.to_f)
75
+ 4.hours.ago # => #<Time:> (now - 4.hours.to_seconds.to_f)
76
+ 5.days.ago # => #<Time:> (now - 5.days.to_seconds.to_f)
77
+ 6.weeks.ago # => #<Time:> (now - 6.weeks.to_seconds.to_f)
78
+ 7.months.ago # => #<Time:> (now - 7.months.to_seconds.to_f)
79
+
80
+ # The future
81
+ 1.millisecond.hence # => #<Time:> (now + 1.millisecond.to_seconds.to_f)
82
+ 2.seconds.hence # => #<Time:> (now + 2.seconds.to_seconds.to_f)
83
+ 3.minutes.hence # => #<Time:> (now + 3.minutes.to_seconds.to_f)
84
+ 4.hours.hence # => #<Time:> (now + 4.hours.to_seconds.to_f)
85
+ 5.days.hence # => #<Time:> (now + 5.days.to_seconds.to_f)
86
+ 6.weeks.hence # => #<Time:> (now + 6.weeks.to_seconds.to_f)
87
+ 7.months.hence # => #<Time:> (now + 7.months.to_seconds.to_f)
88
+ ```
89
+
60
90
  ## Contributing
61
91
 
62
92
  1. Fork it (https://github.com/thoran/duration.rb/fork)
@@ -1,3 +1,3 @@
1
1
  module Duration
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duration.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
10
  date: 2025-10-25 00:00:00.000000000 Z
@@ -44,7 +43,6 @@ homepage: http://github.com/thoran/duration.rb
44
43
  licenses:
45
44
  - Ruby
46
45
  metadata: {}
47
- post_install_message:
48
46
  rdoc_options: []
49
47
  require_paths:
50
48
  - lib
@@ -59,8 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
57
  - !ruby/object:Gem::Version
60
58
  version: '0'
61
59
  requirements: []
62
- rubygems_version: 3.1.6
63
- signing_key:
60
+ rubygems_version: 4.0.0
64
61
  specification_version: 4
65
62
  summary: Objects for handling durations of time.
66
63
  test_files: []