feldtruby 0.2.0 → 0.2.1

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.
@@ -11,6 +11,7 @@ module BasicStatistics
11
11
  def average; mean(); end
12
12
 
13
13
  def median
14
+ return nil if length == 0
14
15
  sorted = self.sort
15
16
  if self.length % 2 == 0
16
17
  mid = self.length / 2
data/lib/feldtruby.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # this is just for Hoe's version numbering
2
2
  class Feldtruby
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  # This is the namespace under which we put things...
6
6
  module FeldtRuby; end
@@ -101,6 +101,10 @@ describe "Basic statistics" do
101
101
  end
102
102
 
103
103
  describe "median" do
104
+ it "works when there is no value" do
105
+ [].median.must_equal nil
106
+ end
107
+
104
108
  it "works when there is a single value" do
105
109
  [1].median.must_equal 1
106
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feldtruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: