w_rate 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e01b2d35c5a54cbfd762f57eafbb023a902cef81
4
- data.tar.gz: 23b2138dab79656251feeb8378aa9893182740fd
3
+ metadata.gz: 9c3aee8623e2d267c5006b96542b8967a723ffb7
4
+ data.tar.gz: 7770375ff8d115e976b7746558a96326089ff3e4
5
5
  SHA512:
6
- metadata.gz: 1bcb3ba1e098c7d40a8ce5044ec68c916ff010911987d92638f099e4aae3dd4d12e80b88a0e70544823a767d69dfbab4d6b6ea3fc6931a2aca724e0a67bdf879
7
- data.tar.gz: 5a71160615e9a761f210caec4277159d14273d5a74ec5f9455a54dad5ac4ece05d40f7ddbe1f9afcc18a2596436a2a7f9fc53b6498d411faade4b6066eddb6b3
6
+ metadata.gz: b885138f4bc92534f9524cf4f22e3e5d033764d98a93f15e19157cebfc37d1ce63e4edf546ada439c1f46789509a985145ec382de36ffcf48722c4b85ac2679a
7
+ data.tar.gz: 13cc48522ead404738c5d1422dda5662f2894a07208f1667a810b3add18ac491b3eb39db78cd5a612307cb1064f4d58e20ea359502d3ddb6965a5edd6d3b9c4b
@@ -1,3 +1,3 @@
1
1
  module WRate
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,3 @@
1
+ module WRate
2
+ VERSION = "0.1.0"
3
+ end
data/lib/w_rate.rb CHANGED
@@ -11,8 +11,8 @@ if votes_count < switch_number
11
11
  rating=(phat+(z*z)/(2*votes_count)+z*Math.sqrt((phat*(1-phat)+(z*z)/(4*votes_count))/votes_count))/(1+(z*z)/votes_count)
12
12
  else
13
13
  rating = (phat+(z*z)/(2*votes_count)-z*Math.sqrt((phat*(1-phat)+(z*z)/(4*votes_count))/votes_count))/(1+(z*z)/votes_count)
14
-
15
- rating=(rating_high+rating_low)/2
14
+ end
16
15
  return rating * v_width + v_min
17
- end
16
+
17
+ end
18
18
  end
data/lib/w_rate.rb~ CHANGED
@@ -1,5 +1,18 @@
1
1
  require "w_rate/version"
2
2
 
3
- module WRate
3
+ class WRate
4
4
  # Your code goes here...
5
+ def rate(sum_rating, votes_count, votes_range = [1, 5], switch_number)
6
+ z = 1.6
7
+ v_min = votes_range.min
8
+ v_width = (votes_range.max - v_min).to_f
9
+ phat = (sum_rating - votes_count.to_f * v_min) / v_width / votes_count.to_f
10
+ if votes_count < switch_number
11
+ rating=(phat+(z*z)/(2*votes_count)+z*Math.sqrt((phat*(1-phat)+(z*z)/(4*votes_count))/votes_count))/(1+(z*z)/votes_count)
12
+ else
13
+ rating = (phat+(z*z)/(2*votes_count)-z*Math.sqrt((phat*(1-phat)+(z*z)/(4*votes_count))/votes_count))/(1+(z*z)/votes_count)
14
+
15
+ rating=(rating_high+rating_low)/2
16
+ return rating * v_width + v_min
17
+ end
5
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: w_rate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siyko
@@ -71,6 +71,7 @@ files:
71
71
  - lib/w_rate.rb
72
72
  - lib/w_rate.rb~
73
73
  - lib/w_rate/version.rb
74
+ - lib/w_rate/version.rb~
74
75
  - w_rate.gemspec
75
76
  - w_rate.gemspec~
76
77
  homepage: ''