nyros_form 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/nyros_form/builder.rb +31 -31
- data/lib/nyros_form/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: 447b001040ffb17463d6da2a4d80a10fe4ad3d740b81fd536b6912646a57446f
|
4
|
+
data.tar.gz: 8f4f666e33217689bf6bea4faa1fade216fa5aabb0d799d4fdff62ee44a86a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 926c10d18c713981a432b88da7f04f5472a0370406b989075cbb92428ac4295f258e51ade6c37d6390bd23c849d0fea69d89063c8a2734c1b3c493e7a1ef6cb6
|
7
|
+
data.tar.gz: d5b646018efc1cfff45d985067c1da23a2aca90684197bde15b11e644b95ddb411c7a88ef9dc55e7d8ba33d22597b2299ac084fb9c8aca2f2a0451d0daed3a83
|
data/Gemfile.lock
CHANGED
data/lib/nyros_form/builder.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class String
|
3
|
+
def integer?
|
4
|
+
return true if self =~ /^[1-9]\d*(\.\d+)?$/
|
5
|
+
false
|
6
|
+
end
|
7
|
+
end
|
8
8
|
|
9
9
|
module NyrosForm
|
10
10
|
|
11
11
|
class Builder
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
12
|
+
def initialize total:, gratuity:
|
13
|
+
@total = total
|
14
|
+
@gratuity = gratuity
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate
|
18
|
+
return calculation if number_based?
|
19
|
+
string_based
|
20
|
+
end
|
21
|
+
|
22
|
+
def number_based?
|
23
|
+
(@gratuity.is_a? Numeric) || (@gratuity.integer?)
|
24
|
+
end
|
25
|
+
|
26
|
+
def string_based
|
27
|
+
case @gratuity.downcase
|
28
|
+
when 'high' then calculation 100
|
29
|
+
when 'standard' then calculation 200
|
30
|
+
when 'low' then calculation 300
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def calculation gratuity = @gratuity
|
35
|
+
@total += @total * (gratuity.to_f / 100)
|
36
|
+
end
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
data/lib/nyros_form/version.rb
CHANGED