was 0.4.0 → 0.5.0
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 +4 -4
- data/README.md +4 -4
- data/lib/was/score.rb +12 -12
- data/lib/was/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8022ee48dc263f90467dd4b9eb9fe4c2125d3a5f4ca14acca80abaa149f53e14
|
4
|
+
data.tar.gz: cda95f6711c8e87b234582a6a0969427824af9c4cbb6f74146b10185bdd4bfb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1693a283d769e0d4b2c96f42c154b39c5c9c8c3bf426befc73e81c938d163ae45ae74385719792966990dfe8f4a5f908915ec06876d003664feafd85e6c9bd89
|
7
|
+
data.tar.gz: 12cfc53b40541711c802191e428fabe75cb93b3f648255f181f6b378f05750441843829cab4264ad5dfae765d82f7a7f211b8c5b0189abc8fcce40978e2603d7
|
data/README.md
CHANGED
@@ -25,8 +25,8 @@ require "was"
|
|
25
25
|
class ReportScore < WAS::Score
|
26
26
|
maximum_score 1000
|
27
27
|
|
28
|
-
with "ExamScore", weight: 0.75
|
29
|
-
with "PracticalScore", weight: 0.25
|
28
|
+
with :exam, "ExamScore", weight: 0.75
|
29
|
+
with :practical "PracticalScore", weight: 0.25
|
30
30
|
end
|
31
31
|
|
32
32
|
class ExamScore < WAS::Score
|
@@ -68,8 +68,8 @@ Omitting the `maximum_score` will return a composed percentage represented as a
|
|
68
68
|
```ruby
|
69
69
|
# report_score.rb
|
70
70
|
class ReportScore < WAS::Score
|
71
|
-
with "ExamScore", weight: 0.75
|
72
|
-
with "PracticalScore", weight: 0.25
|
71
|
+
with :exam, "ExamScore", weight: 0.75
|
72
|
+
with :practical "PracticalScore", weight: 0.25
|
73
73
|
end
|
74
74
|
```
|
75
75
|
|
data/lib/was/score.rb
CHANGED
@@ -10,21 +10,21 @@ module WAS
|
|
10
10
|
@maximum_score || 1
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.with(klass, weight: 0)
|
14
|
-
|
13
|
+
def self.with(name, class_name: klass, weight: 0)
|
14
|
+
scorers.merge!(name => { class_name: class_name, weight: weight })
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.
|
18
|
-
@
|
17
|
+
def self.scorers
|
18
|
+
@scorers ||= {}
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.weights
|
22
22
|
{}.tap do |hash|
|
23
|
-
|
24
|
-
hash[
|
25
|
-
if Object.const_get(
|
26
|
-
hash[
|
27
|
-
with: Object.const_get(
|
23
|
+
scorers.each do |name, scorer|
|
24
|
+
hash[name] = { weight: scorer[:weight] }
|
25
|
+
if Object.const_get(scorer[:class_name]).scorers.length > 0
|
26
|
+
hash[name].merge!(
|
27
|
+
with: Object.const_get(scorer[:class_name]).weights
|
28
28
|
)
|
29
29
|
end
|
30
30
|
end
|
@@ -40,9 +40,9 @@ module WAS
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def calculation
|
43
|
-
self.class.
|
44
|
-
score = Object.const_get(
|
45
|
-
score * weight
|
43
|
+
self.class.scorers.sum do |name, scorer|
|
44
|
+
score = Object.const_get(scorer[:class_name]).new(input[name.to_sym]).calculate
|
45
|
+
score * scorer[:weight]
|
46
46
|
end * self.class.max_score
|
47
47
|
end
|
48
48
|
|
data/lib/was/version.rb
CHANGED