cinch-toolbox 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cinch-toolbox/version.rb +1 -1
- data/lib/cinch-toolbox.rb +5 -3
- metadata +2 -2
data/lib/cinch-toolbox.rb
CHANGED
@@ -78,7 +78,7 @@ module Cinch
|
|
78
78
|
# Used to render a period of time in a uniform string.
|
79
79
|
# There is probably a much better way to do this, so FIXME
|
80
80
|
# @param [Fixnum] secs Number of seconds to render into a string.
|
81
|
-
def Toolbox.time_format(secs)
|
81
|
+
def Toolbox.time_format(secs, units = nil)
|
82
82
|
data = { :days => (secs / 86400).floor,
|
83
83
|
:hours => ((secs % 86400) / 3600).floor,
|
84
84
|
:mins => ((secs % 3600) / 60).floor,
|
@@ -86,10 +86,12 @@ module Cinch
|
|
86
86
|
string = []
|
87
87
|
data.keys.map do |period|
|
88
88
|
if period == :secs || !(data[period].zero? && string.empty?)
|
89
|
-
|
89
|
+
if units.nil? || units.include?(period)
|
90
|
+
string << "#{data[period]} #{period}"
|
91
|
+
end
|
90
92
|
end
|
91
93
|
end
|
92
|
-
return string.join(' ')
|
94
|
+
return string.join(', ')
|
93
95
|
end
|
94
96
|
|
95
97
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|