Skip to content
Browse files

Fix clobber detection on 1.9

  • Loading branch information...
1 parent 4a7c6e7 commit 255853f7c564398cf5426b9fdc90e3dc22f10e0d @justincampbell justincampbell committed
Showing with 9 additions and 8 deletions.
  1. +9 −8 lib/easystats.rb
View
17 lib/easystats.rb
@@ -4,8 +4,9 @@ def mean
return unless self.any?
self.sum / self.count.to_f
- end unless Array.instance_methods.include? "mean"
- alias_method :average, :mean unless Array.instance_methods.include? "average"
+ end unless Array.method_defined? :mean
+
+ alias_method :average, :mean unless Array.method_defined? :average
# take in the array of numbers and calculate the median
def median
@@ -29,7 +30,7 @@ def median
end
median
- end unless Array.instance_methods.include? "median"
+ end unless Array.method_defined? :median
# take in an array of numbers and return the mode
def mode
@@ -91,7 +92,7 @@ def mode
highest_value
end
end
- end unless Array.instance_methods.include? "mode"
+ end unless Array.method_defined? :mode
# take in an array of numbers and calculate the range
def range
@@ -99,7 +100,7 @@ def range
data = self.sort
data.last - data.first
- end unless Array.instance_methods.include? "range"
+ end unless Array.method_defined? :range
# take in an array of numbers and calculate the standard deviation
def standard_deviation
@@ -107,18 +108,18 @@ def standard_deviation
return 0 if self.one?
Math::sqrt(self.sum_of_deviations_squared / (self.count-1))
- end unless Array.instance_methods.include? "standard_deviation"
+ end unless Array.method_defined? :standard_deviation
# take in an array of numbers and calculate the sum
def sum
self.reduce { |total, number| total + number }
- end unless Array.instance_methods.include? "sum"
+ end unless Array.method_defined? :sum
def variance
return unless self.any?
self.sum_of_deviations_squared / self.count.to_f
- end unless Array.instance_methods.include? "variance"
+ end unless Array.method_defined? :variance
protected

0 comments on commit 255853f

Please sign in to comment.
Something went wrong with that request. Please try again.