tippy-weston 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/Gemfile.lock +1 -1
- data/lib/tippy/weston/builder.rb +32 -29
- data/lib/tippy/weston/version.rb +1 -1
- data/tippy-weston.gemspec +3 -3
- 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: 2b45406c68a16d3e8eefe0f2b5f82c61c5f0cdf07de56149582c3cef8ee6e0c9
|
|
4
|
+
data.tar.gz: ebcff7c57cb2bbf192ebd04cebaafd18746029dd07fdfbff3e9f892fe1aba0c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c01ba925cdbe8c64a1359e40d6b19b3ab8eabace193ef15853d852ae20927211513c7e312c05a17b83a1b62c87ddaa2cd17ebd45abed55db08c1812b8e6144d
|
|
7
|
+
data.tar.gz: a03c06cce5d288fb472f8219d5378d8f917c35bbaf0e65219fc00efb86d553f1d8d1e2a9a0c30e398c163a39cb905250409be3194f28089adf2670656dc528cc
|
data/Gemfile.lock
CHANGED
data/lib/tippy/weston/builder.rb
CHANGED
|
@@ -1,39 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Tippy
|
|
4
|
+
module Weston
|
|
5
|
+
# Gotta love Builder
|
|
2
6
|
class Builder
|
|
7
|
+
def initialize(total:, gratuity:)
|
|
8
|
+
@total = total
|
|
9
|
+
@gratuity = gratuity
|
|
10
|
+
end
|
|
3
11
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@gratuity = gratuity
|
|
7
|
-
end
|
|
12
|
+
def generate
|
|
13
|
+
return total_accumulator if number_based?
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return total_accumulator
|
|
12
|
-
end
|
|
13
|
-
string_based
|
|
14
|
-
end
|
|
15
|
+
string_based
|
|
16
|
+
end
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
private
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
def total_accumulator(gratuity = @gratuity)
|
|
21
|
+
@total += @total * (gratuity.to_f / 100)
|
|
22
|
+
end
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
def number_based?
|
|
25
|
+
@gratuity.is_a?(Numeric) || @gratuity.integer?
|
|
26
|
+
end
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
28
|
+
def string_based
|
|
29
|
+
case @gratuity.downcase
|
|
30
|
+
when "high"
|
|
31
|
+
total_accumulator(25.0)
|
|
32
|
+
when "standard"
|
|
33
|
+
total_accumulator(20.0)
|
|
34
|
+
when "low"
|
|
35
|
+
total_accumulator(15.0)
|
|
36
|
+
else
|
|
37
|
+
total_accumulator(20.0)
|
|
37
38
|
end
|
|
39
|
+
end
|
|
38
40
|
end
|
|
39
|
-
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/tippy/weston/version.rb
CHANGED
data/tippy-weston.gemspec
CHANGED
|
@@ -9,16 +9,16 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = ["51345538+Wcarpenter96@users.noreply.github.com"]
|
|
10
10
|
|
|
11
11
|
spec.summary = "A gem for generating tip values based on a number of inputs."
|
|
12
|
-
# spec.description = "TODO: Write a longer description or delete this line."
|
|
12
|
+
# spec.description = "TODO: Write a longer description or delete this line."
|
|
13
13
|
spec.homepage = "https://github.com/Wcarpenter96/tippy-weston"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
|
16
16
|
|
|
17
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
|
18
18
|
|
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
20
20
|
spec.metadata["source_code_uri"] = "https://github.com/Wcarpenter96/tippy-weston"
|
|
21
|
-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
21
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
22
22
|
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|