test_semano 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 +4 -4
- data/lib/test_semano/builder.rb +19 -20
- data/lib/test_semano/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: 7921da32c7bd48f35caaf2e73e7f8e3fe4f72b70a2fb4102cf604af8b351df6e
|
|
4
|
+
data.tar.gz: 3a2aaf5ad5a7c10dd041027d06c84c4e7287e596b3968eba6dfcd95c267b8f6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed790a234c1548b0c86e3d84b47585d6db81000826a11c09f09e2044b6ea1d4b30241f8639bcb413467fe891269201422c80f9beb9e255bb1f42adf157b8d29f
|
|
7
|
+
data.tar.gz: c4044329411d353dfd8eb9f98eaf80c0a5a9c91ffd1d0fc519ea3ad04bd4ee3fb4eb8f43647e8559bf395e413ee76e78d0341fc6bb0a003a745369333ee4e38d
|
data/lib/test_semano/builder.rb
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
class String
|
|
2
|
+
def integer?
|
|
3
|
+
return true if self =~ /^[1-9]\d+(\.\d+)?$/
|
|
4
|
+
false
|
|
5
|
+
end
|
|
6
|
+
end
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
module TestSemano
|
|
9
|
+
class Builder
|
|
10
|
+
def initialize(total:, graduity:)
|
|
6
11
|
@total = total
|
|
7
12
|
@graduity = graduity
|
|
8
13
|
end
|
|
9
14
|
|
|
10
15
|
def generate
|
|
11
|
-
return calculation if number_based
|
|
12
|
-
string_based
|
|
16
|
+
return calculation if number_based
|
|
17
|
+
string_based
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
def number_based
|
|
16
|
-
@graduity.is_a?
|
|
21
|
+
(@graduity.is_a? Numeric) || (@graduity.integer?)
|
|
17
22
|
end
|
|
18
23
|
|
|
19
24
|
def string_based
|
|
20
|
-
case @graduity.
|
|
21
|
-
when "low"
|
|
22
|
-
|
|
23
|
-
when "
|
|
24
|
-
@total + 0.15
|
|
25
|
-
when "high"
|
|
26
|
-
@total + 0.2
|
|
27
|
-
else
|
|
28
|
-
@total
|
|
25
|
+
case @graduity.downcase
|
|
26
|
+
when "low" then calculation 15
|
|
27
|
+
when "high" then calculation 25
|
|
28
|
+
when "standard" then calculation 18
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def calculation
|
|
33
|
-
@total += @total *(@graduity.to_f/100)
|
|
32
|
+
def calculation graduity = @graduity
|
|
33
|
+
@total += @total * (@graduity.to_f/100)
|
|
34
34
|
end
|
|
35
|
-
|
|
36
35
|
end
|
|
37
36
|
|
|
38
|
-
end
|
|
37
|
+
end
|
data/lib/test_semano/version.rb
CHANGED