utilities 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -108,6 +108,7 @@ Usage
108
108
  [1,2,3,3,4,4,4,5].modes #=> {4=>3}
109
109
 
110
110
  * statistics
111
+
111
112
  [1,2,3,4,5].statistics #=> {
112
113
  :first=>1,
113
114
  :last=>5,
@@ -115,7 +116,7 @@ Usage
115
116
  :sum=>15,
116
117
  :squares=>[1, 4, 9, 16, 25],
117
118
  :sqrts=>[1.0, 1.4142135623730951, 1.7320508075688772, 2.0, 2.23606797749979],
118
- :min=>1,population sample variance
119
+ :min=>1,
119
120
  :max=>5,
120
121
  :mean=>3.0,
121
122
  :frequences=>{1=>1, 2=>1, 3=>1, 4=>1, 5=>1},
@@ -8,4 +8,10 @@ class String
8
8
  def to_time
9
9
  Time.parse(self)
10
10
  end
11
+
12
+ # Transform a string of format HH:MM into a float representing an hour
13
+ def hour_to_float(separator=':')
14
+ m, s = self.split(separator).map(&:to_f)
15
+ m + (s / 60)
16
+ end
11
17
  end
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Utilities
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- BUILD = 17
4
+ BUILD = 18
5
5
 
6
6
  VERSION = "#{MAJOR}.#{MINOR}.#{BUILD}"
7
7
  end
@@ -130,6 +130,13 @@ describe Range do
130
130
  end
131
131
  end
132
132
 
133
+ describe String do
134
+ it "#hour_to_float should returns a float represention of the hour" do
135
+ "14:30".hour_to_float.should == 14.5
136
+ "03h12".hour_to_float('h').should == 3.2
137
+ end
138
+ end
139
+
133
140
  describe Utilities::Statistics do
134
141
  it "#statistics should returns a hash with all statistics included" do
135
142
  [1,2,3,4,5].to_stats.statistics.should == {
@@ -139,7 +146,7 @@ describe Utilities::Statistics do
139
146
  :sum=>15,
140
147
  :squares=>[1, 4, 9, 16, 25],
141
148
  :sqrts=>[1.0, 1.4142135623730951, 1.7320508075688772, 2.0, 2.23606797749979],
142
- :min=>1,population sample variance
149
+ :min=>1,
143
150
  :max=>5,
144
151
  :mean=>3.0,
145
152
  :frequences=>{1=>1, 2=>1, 3=>1, 4=>1, 5=>1},
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-09-02 00:00:00.000000000Z
14
+ date: 2011-09-06 00:00:00.000000000Z
15
15
  dependencies: []
16
16
  description: Few utilities include in all my projects, including a module for statistics,
17
17
  some to_date and to_time functions as well as intersection method for Range object.
@@ -38,7 +38,7 @@ files:
38
38
  - lib/utilities/utilities.rb
39
39
  - lib/version.rb
40
40
  - test/test_utilities.rb
41
- - utilities-0.0.15.gem
41
+ - utilities-0.0.17.gem
42
42
  - utilities.gemspec
43
43
  homepage: http://github.com/christianblais/utilities
44
44
  licenses: []
data/utilities-0.0.15.gem DELETED
Binary file