tipping_gem 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc15c3cbfc5a1ae54dfb1334164dba8a4c825aeb28551c3be7ab435f29ecc204
4
+ data.tar.gz: 99de6a78c85695ee15322854f76982c7331051e5f04c298d4f173cc6230c2e6b
5
+ SHA512:
6
+ metadata.gz: ff2fcdde0d123580d935f13180ab2903f5e098314ac6e87248109c50d0dde67a9832a3520fb568b98bfc7e4290b273e157c93d54c59ece0820f395fac18ad661
7
+ data.tar.gz: 683df3490f2e865da00e6d0ae8629995cc2249bb43ff80967be53273bcf3342192311aa30c7ea86c519a56fdde6f51363a9a63735d48fe86d08bcdebc13c9350
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tipping_gem.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tipping_gem (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (12.3.3)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ rake (~> 12.0)
16
+ tipping_gem!
17
+
18
+ BUNDLED WITH
19
+ 2.1.4
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # TippingGem
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'tipping_gem'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tipping_gem
18
+
19
+ ## Usage
20
+
21
+ TippingGem::Builder.new(total: 100, Tip: '18.5').generate # 118.5
22
+ TippingGem::Builder.new(total: 100, Tip: 'Five').generate # 105
23
+ TippingGem::Builder.new(total: 100, Tip: 'Ten').generate # 110
24
+ TippingGem::Builder.new(total: 100, Tip: 'Fifteen').generate # 115
25
+ TippingGem::Builder.new(total: 100, Tip: 'Twenty').generate # 118.5
26
+ TippingGem::Builder.new(total: 100, Tip: 100).generate # 200
27
+
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tipping_gem.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tipping_gem"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require "tipping_gem/version"
2
+ require "tipping_gam/builder"
3
+
4
+ module TippingGem
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,32 @@
1
+ module TippingGem
2
+
3
+ class Builder
4
+ def initialize total:, gratuity:
5
+ @total = total
6
+ @gratuity = gratuity
7
+ end
8
+
9
+ ##check if input is a number or a string from the button pressed.
10
+ def generate
11
+ return calculation if number_based?
12
+ string_based
13
+ end
14
+
15
+ def number_based?
16
+ (@gratuity.is_a? Numeric) || (@gratuity.integer?)
17
+ end
18
+
19
+ def string_based
20
+ case @gratuity.downcase
21
+ when 'five' then calculation 5
22
+ when 'ten' then calculation 10
23
+ when 'fifteen' then calculation 15
24
+ when 'twenty' then calculation 20
25
+ end
26
+ end
27
+
28
+ def calculation gratuity = @gratuity
29
+ @total += @total * (gratuity.to_f / 100)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module TippingGem
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'lib/tipping_gem/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "tipping_gem"
5
+ spec.version = TippingGem::VERSION
6
+ spec.authors = ["JellieBeanz"]
7
+ spec.email = ["shaneoneill1995@gmail.com"]
8
+
9
+ spec.summary = %q{Gem for tipping a post}
10
+ spec.homepage = "https://github.com/JellieBeanz/TippingGem.git"
11
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+
13
+
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tipping_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - JellieBeanz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - shaneoneill1995@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - README.md
24
+ - Rakefile
25
+ - bin/console
26
+ - bin/setup
27
+ - lib/tipping_gem.rb
28
+ - lib/tipping_gem/builder.rb
29
+ - lib/tipping_gem/version.rb
30
+ - tipping_gem.gemspec
31
+ homepage: https://github.com/JellieBeanz/TippingGem.git
32
+ licenses: []
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.3.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.1.2
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Gem for tipping a post
53
+ test_files: []