creative_rails_utilities 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08df32abe84df0ba17bcd247dd52a6714f584a79
4
- data.tar.gz: 6bd9acbc35e7926b8ce57f35c6fa7d693b29f101
3
+ metadata.gz: 942d11bff39c8a0304c0486b6d16ae7f5d5a9782
4
+ data.tar.gz: 79d15bd93fd7dacc1c932fd4577c5501fa988a08
5
5
  SHA512:
6
- metadata.gz: 4621a27d1b6cd706c1c6c417b5c093ce9de3da2e2bc9a6483754a5b1a929853b25d84d4adca3ba707fb3ddbdc4aedac908471800385845beb9ab98ab8d52e796
7
- data.tar.gz: c28e943c38a022b676f6d132ce13104d0551acedff88388133fac2aeee3a051e8c7ca6766c11cb98a5c8274bc2ce6550f890763bacf762ec1ebcd82055f5a6d1
6
+ metadata.gz: f6d975dea6bf6654956122e50a268335469d0616660a8e4fda389ec2d7aadd3c2e29c812f97709cec4d7e211433aa4c854b510a17a854d6317032ed3b9fcc237
7
+ data.tar.gz: e127ec706ad345a6d175b645a2fd6778e3046b5ec414d402e2f61ce16dd28a5e3af1a1feaac787d9eb446d9ed1eaf25d3c1f728bc4d1cd237cacdced33efbf43
data/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
8
8
  -
9
9
  ```
10
10
 
11
+ ## [0.3.3] - 2016-04-19
12
+ ### Added
13
+ - Numeric#to_time_hash
14
+
11
15
  ## [0.3.2] - 2016-04-19
12
16
  ### Added
13
17
  - String#to_bool
data/README.md CHANGED
@@ -6,7 +6,7 @@ Intended for `Rails >= 4.0.0`, but will probably work for older projects with ro
6
6
 
7
7
  ## Installation
8
8
 
9
- `gem 'creative_rails_utilities', "~> 0.3.2"` and `bundle`
9
+ `gem 'creative_rails_utilities', "~> 0.3.3"` and `bundle`
10
10
 
11
11
  ## Usage
12
12
 
@@ -142,6 +142,13 @@ some_hash.fast_sort_keys #=> some_sorted_hash
142
142
  0.safe_percent(0) #=> 0
143
143
  ```
144
144
 
145
+ ```ruby
146
+ # transform a Numeric that denotes seconds into a hash of how many :days, :hours, :minutes ad :seconds that is
147
+ 61.5.to_time_hash #=> {days: 0, hours: 0, minutes: 1, seconds: 1.5}
148
+ 2775721.to_time_hash #=> {days: 32, hours: 3, minutes: 2, seconds: 1}
149
+ (Time.zone.now.to_i - 3.minutes.ago.to_i).to_time_hash #=> {days: 0, hours: 0, minutes: 3, seconds: 0}
150
+ ```
151
+
145
152
  ##### String
146
153
 
147
154
  ```ruby
@@ -170,6 +177,7 @@ string #=> "1..." instead of " 1..."
170
177
  ```ruby
171
178
  # Convert string to boolean.
172
179
  "true".to_bool #=> true
180
+ "faLSE".to_bool #=> false # yup, case insensitive
173
181
  "0".to_bool #=> false
174
182
  "".to_bool #=> false
175
183
  "y".to_bool #=> true
@@ -43,4 +43,17 @@ class Numeric
43
43
  end
44
44
  end
45
45
 
46
+ def to_time_hash
47
+ mm, ss = self.divmod(60)
48
+ hh, mm = mm.divmod(60)
49
+ dd, hh = hh.divmod(24)
50
+
51
+ return {
52
+ days: dd,
53
+ hours: hh,
54
+ minutes: mm,
55
+ seconds: ss,
56
+ }
57
+ end
58
+
46
59
  end
@@ -1,3 +1,3 @@
1
1
  module CreativeRailsUtilities
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creative_rails_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Creative