tippy_mun 0.1.7 → 0.1.8
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/tippy_mun/builder.rb +28 -28
- data/lib/tippy_mun/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f9c091e3105ad7290ea03b883f1f10be3dde54e
|
4
|
+
data.tar.gz: 302d46d01477c4c40fc3864518fc233779219892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb744b2ebedfc45b51e840085007b048ac331ac3964b787edfae0e9734f6cc0019ea4adef73decb1bfc63b98319d0b6f86b462231202d3138ada4e5a9027ff33
|
7
|
+
data.tar.gz: 6ae6a5b70742def36a77064431968ebe91576fecf479f702d5cf6c0908d54144d03ef8066e6e26fd27eea3b7228feb11a6680b3531c97314391b816260e9fdd7
|
data/Gemfile.lock
CHANGED
data/lib/tippy_mun/builder.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
lass String
|
2
|
+
def integer?
|
3
|
+
return true if self =~ /^[1-9]\d*(\.\d+)?$/
|
4
|
+
false
|
5
|
+
end
|
6
6
|
end
|
7
7
|
|
8
8
|
module TippyMun
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
class Builder
|
11
|
+
def initialize total:, gratuity:
|
12
|
+
@total = total
|
13
|
+
@gratuity = gratuity
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def generate
|
17
|
+
return calculation if number_based?
|
18
|
+
string_based
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def number_based?
|
22
|
+
(@gratuity.is_a? Numeric) || (@gratuity.integer?)
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
def string_based
|
26
|
+
case @gratuity.downcase
|
27
|
+
when 'high' then calculation 25
|
28
|
+
when 'standard' then calculation 18
|
29
|
+
when 'low' then calculation 15
|
30
|
+
end
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def calculation gratuity = @gratuity
|
34
|
+
@total += @total * (gratuity.to_f / 100)
|
35
|
+
end
|
36
|
+
end
|
37
37
|
|
38
38
|
end
|
data/lib/tippy_mun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tippy_mun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Munir
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|