assumption 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 +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +10 -0
- data/assumption.gemspec +38 -0
- data/bin/assumption +6 -0
- data/bin/console +18 -0
- data/bin/setup +8 -0
- data/config/environment.rb +15 -0
- data/lib/assumption.rb +5 -0
- data/lib/assumption/chart_data_set.rb +32 -0
- data/lib/assumption/cli.rb +48 -0
- data/lib/assumption/concerns/uni_functions.rb +51 -0
- data/lib/assumption/data_importer.rb +38 -0
- data/lib/assumption/game.rb +120 -0
- data/lib/assumption/song.rb +9 -0
- data/lib/assumption/version.rb +3 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 011dc0d3f286021e0795857c70a9f0cf0df9c4aaaa05f5a2f6851639e2b5f74b
|
4
|
+
data.tar.gz: e65373e4335ce1e5be1db7e211965d8fc8473c9d48d1821d6fdcee6d8061b903
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c512147bc5bae59810d35c9bc816590e3a220fdfc5b6500f0f03d7ccdacb96adc4446f8115a9896c0ae700c16943454359576e8365be6cb87794110c5e6cee9
|
7
|
+
data.tar.gz: f142208cfe9e792fc6af421d2ff80de704264ca0b01de76fe24268f693ae31501444962722e6a83305f3d885290a92cf089c18e25401a7c160d9bbf47bb07e6a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dannyboy.msn@hotmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
assumption (0.1.0)
|
5
|
+
bundler (~> 2.0)
|
6
|
+
minitest (~> 5.0)
|
7
|
+
nokogiri
|
8
|
+
pry
|
9
|
+
rake (~> 10.0)
|
10
|
+
tco (~> 0.1.8)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
coderay (1.1.2)
|
16
|
+
method_source (0.9.2)
|
17
|
+
mini_portile2 (2.4.0)
|
18
|
+
minitest (5.12.2)
|
19
|
+
nokogiri (1.10.4)
|
20
|
+
mini_portile2 (~> 2.4.0)
|
21
|
+
pry (0.12.2)
|
22
|
+
coderay (~> 1.1.0)
|
23
|
+
method_source (~> 0.9.0)
|
24
|
+
rake (10.5.0)
|
25
|
+
tco (0.1.8)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
assumption!
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 DBuckley0126
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# assumption
|
2
|
+
Flatiron: CLI Scrapper Game
|
3
|
+
|
4
|
+
A Command-line interface game which the user can select a year and play assume if a song is higher or lower in the chart.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'assumption'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install assumption
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
You will be promted to enter a year between 1952 - 2019.
|
25
|
+
Press enter and you will be shown 2 songs from the top 100 chart music from that year.
|
26
|
+
|
27
|
+
You can enter 'h' to say that the second song is higher up in the chart than the first presented song,
|
28
|
+
or you can enter 'l' to say that the second song is lower in the chart than the first presented song.
|
29
|
+
|
30
|
+
If you are correct, you will go up a level.
|
31
|
+
The aim of the game is to get to the highest level.
|
32
|
+
|
33
|
+
If you loose, you can replay the game by pressing 'y' when prompted or you can press 'n' to quit game.
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
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).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/assumption. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
48
|
+
|
49
|
+
## Code of Conduct
|
50
|
+
|
51
|
+
Everyone interacting in the assumption project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/assumption/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/assumption.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "assumption/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "assumption"
|
7
|
+
spec.version = Assumption::VERSION
|
8
|
+
spec.authors = ["DBuckley0126"]
|
9
|
+
spec.email = ["dannyboy.msn@hotmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Flatiron: CLI Scrapper Game"
|
12
|
+
spec.description = "A Command-line interface game which the user can select a year and play assume if a song is higher or lower in the chart"
|
13
|
+
spec.homepage = "https://github.com/DBuckley0126/Assumption-CLI"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = "https://github.com/DBuckley0126/CLI-Game-Assumption"
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/DBuckley0126/CLI-Game-Assumption"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/DBuckley0126/CLI-Game-Assumption"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "bin"
|
28
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.executables = ["assumption"]
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
spec.add_dependency 'bundler', '~> 2.0'
|
33
|
+
spec.add_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_dependency 'minitest', '~> 5.0'
|
35
|
+
spec.add_dependency 'pry', '>= 0'
|
36
|
+
spec.add_dependency 'nokogiri', '>= 0'
|
37
|
+
spec.add_dependency 'tco', '~> 0.1.8'
|
38
|
+
end
|
data/bin/assumption
ADDED
data/bin/console
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require '/mnt/c/users/Danny.Dannys_PC/dev/flatiron/CLI-Data-Gem-Project/assumption/config/environment.rb'
|
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 'pry'
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'tco'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'io/console'
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
|
8
|
+
require_relative '../lib/assumption/version'
|
9
|
+
require_relative '../lib/assumption'
|
10
|
+
require_relative '../lib/assumption/concerns/uni_functions'
|
11
|
+
require_relative '../lib/assumption/cli'
|
12
|
+
require_relative '../lib/assumption/chart_data_set'
|
13
|
+
require_relative '../lib/assumption/game'
|
14
|
+
require_relative '../lib/assumption/data_importer'
|
15
|
+
require_relative '../lib/assumption/song'
|
data/lib/assumption.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class Assumption::ChartDataSet
|
2
|
+
|
3
|
+
@@all = []
|
4
|
+
|
5
|
+
def self.find_or_create_by_year(year)
|
6
|
+
var = self.all.find { |set| set.year == year}
|
7
|
+
var ? var : Assumption::ChartDataSet.new(year)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.all
|
11
|
+
@@all
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :chart_array, :year
|
15
|
+
|
16
|
+
def initialize(year)
|
17
|
+
@year = year
|
18
|
+
@chart_song_array = Assumption::DataImporter.new(year).output
|
19
|
+
@@all << self
|
20
|
+
@last_choosen = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def random
|
24
|
+
output = @chart_song_array.sample
|
25
|
+
if output == @last_choosen
|
26
|
+
self.random
|
27
|
+
end
|
28
|
+
@last_choosen = output
|
29
|
+
output
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Assumption::CLI
|
2
|
+
|
3
|
+
include UniFunctions
|
4
|
+
|
5
|
+
attr_accessor :input
|
6
|
+
|
7
|
+
def start_sequence
|
8
|
+
clear_terminal
|
9
|
+
title
|
10
|
+
self.begin
|
11
|
+
end
|
12
|
+
|
13
|
+
def begin
|
14
|
+
puts 'Type the chart year you would like to play between 1954-2019'
|
15
|
+
|
16
|
+
year_input
|
17
|
+
|
18
|
+
puts 'Would you like to play again? (y/n)'
|
19
|
+
get_char
|
20
|
+
@input == 'y' ? start_sequence : exit
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def year_input
|
26
|
+
@input = gets
|
27
|
+
#binding.pry
|
28
|
+
if (1954..2019).include?(@input.to_i)
|
29
|
+
Assumption::Game.new(@input.to_i)
|
30
|
+
elsif @input.strip == "random"
|
31
|
+
Assumption::Game.new(random_year)
|
32
|
+
elsif @input.strip.to_s.size != 4
|
33
|
+
puts 'Must be 4 digits'
|
34
|
+
year_input
|
35
|
+
elsif !(1954..2019).include?(@input.to_i)
|
36
|
+
puts 'Must be within 1954-2019'
|
37
|
+
year_input
|
38
|
+
else
|
39
|
+
puts 'Error'
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def random_year
|
45
|
+
rand(1954..2019)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module UniFunctions
|
2
|
+
|
3
|
+
def clear_terminal
|
4
|
+
system "clear"
|
5
|
+
system "cls"
|
6
|
+
end
|
7
|
+
|
8
|
+
def underline
|
9
|
+
50.times do
|
10
|
+
print "="
|
11
|
+
sleep(0.01)
|
12
|
+
end
|
13
|
+
puts "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
|
18
|
+
puts ' ___ _ _ '
|
19
|
+
sleep(0.1)
|
20
|
+
puts ' / _ \ | | (_) '
|
21
|
+
sleep(0.1)
|
22
|
+
puts '/ /_\ \___ ___ _ _ _ __ ___ _ __ | |_ _ ___ _ __ '
|
23
|
+
sleep(0.1)
|
24
|
+
puts '| _ / __/ __| | | | _ ` _ \| _ \| __| |/ _ \| _ \ '
|
25
|
+
sleep(0.1)
|
26
|
+
puts '| | | \__ \__ \ |_| | | | | | | |_) | |_| | (_) | | | |'
|
27
|
+
sleep(0.1)
|
28
|
+
puts '\_| |_/___/___/\__,_|_| |_| |_| .__/ \__|_|\___/|_| |_|'
|
29
|
+
sleep(0.1)
|
30
|
+
puts ' | | '
|
31
|
+
sleep(0.1)
|
32
|
+
puts ' |_| '
|
33
|
+
puts ""
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
def get_char
|
39
|
+
state = `stty -g`
|
40
|
+
`stty raw -echo -icanon isig`
|
41
|
+
|
42
|
+
Signal.trap("INT") do # SIGINT = control-C
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
self.input = STDIN.getc.chr
|
47
|
+
ensure
|
48
|
+
`stty #{state}`
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Assumption::DataImporter
|
2
|
+
|
3
|
+
include UniFunctions
|
4
|
+
|
5
|
+
attr_reader :output
|
6
|
+
attr_writer :input
|
7
|
+
|
8
|
+
def initialize (year)
|
9
|
+
|
10
|
+
begin
|
11
|
+
html = open("http://www.uk-charts.top-source.info/top-100-#{year}.shtml")
|
12
|
+
rescue OpenURI::HTTPError => error
|
13
|
+
response = error.io
|
14
|
+
clear_terminal
|
15
|
+
puts "Source error, please contact gem creator"
|
16
|
+
puts response.status
|
17
|
+
puts "Press any key to exit"
|
18
|
+
get_char
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
doc = Nokogiri::HTML(html)
|
23
|
+
@output = transform(doc)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def transform(doc)
|
30
|
+
obj_array = []
|
31
|
+
doc.css("table.sortable tbody tr").each do |row|
|
32
|
+
song = Assumption::Song.new(row.css("td")[0].text.to_i, row.css("td")[2].text.split.map(&:capitalize).join(' '), row.css("td")[1].text.split.map(&:capitalize).join(' '))
|
33
|
+
obj_array << song
|
34
|
+
end
|
35
|
+
obj_array
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
class Assumption::Game
|
2
|
+
|
3
|
+
include UniFunctions
|
4
|
+
|
5
|
+
|
6
|
+
@@all = []
|
7
|
+
|
8
|
+
def self.all
|
9
|
+
@@all
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :input
|
13
|
+
|
14
|
+
attr_reader :year, :chart_data_set, :id
|
15
|
+
|
16
|
+
def initialize(year)
|
17
|
+
@year = year
|
18
|
+
@chart_data_set = Assumption::ChartDataSet.find_or_create_by_year(year)
|
19
|
+
@level = 1
|
20
|
+
@@all << self
|
21
|
+
@current_song = @chart_data_set.random
|
22
|
+
@next_song = @chart_data_set.random
|
23
|
+
@input = nil
|
24
|
+
start_level
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def start_level
|
30
|
+
|
31
|
+
clear_terminal
|
32
|
+
puts "Level #{@level}.".fg("#D13DDB")
|
33
|
+
underline
|
34
|
+
puts "In #{year},"
|
35
|
+
puts "was #{@next_song.artist} - #{@next_song.name}"
|
36
|
+
puts "higher or lower in the chart".fg("#147CEE")
|
37
|
+
puts "than #{@current_song.artist} - #{@current_song.name}"
|
38
|
+
|
39
|
+
answer_input
|
40
|
+
end
|
41
|
+
|
42
|
+
def round_logic
|
43
|
+
@position_dif = @next_song.position - @current_song.position
|
44
|
+
|
45
|
+
@input == "h" ? @higher_input = true : @higher_input = false
|
46
|
+
|
47
|
+
if @next_song.position < @current_song.position
|
48
|
+
@higher_input ? next_level(@position_dif.abs, "higher") : end_level(@position_dif.abs, "lower")
|
49
|
+
elsif @next_song.position > @current_song.position
|
50
|
+
!@higher_input ? next_level(@position_dif.abs, "lower") : end_level(@position_dif.abs, "higher")
|
51
|
+
else
|
52
|
+
put "Error in the game"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def next_level(position_dif, direction)
|
57
|
+
underline
|
58
|
+
puts "Correct: Level Up!".fg("#1ADF36")
|
59
|
+
|
60
|
+
if direction == "higher" #user picked a decision of higher that is right.
|
61
|
+
puts "You choose higher"
|
62
|
+
next_song_info
|
63
|
+
current_song_info
|
64
|
+
puts "#{@next_song.name} is #{position_dif} places above"
|
65
|
+
|
66
|
+
else #user picked a decision of lower that is right.
|
67
|
+
puts "You choose lower"
|
68
|
+
current_song_info
|
69
|
+
next_song_info
|
70
|
+
puts "#{@next_song.name} is #{position_dif} places below"
|
71
|
+
end
|
72
|
+
|
73
|
+
@level += 1
|
74
|
+
@current_song = @next_song
|
75
|
+
@next_song = @chart_data_set.random
|
76
|
+
puts ""
|
77
|
+
puts "Press any key to continue"
|
78
|
+
get_char
|
79
|
+
start_level
|
80
|
+
end
|
81
|
+
|
82
|
+
def end_level (position_dif, decision)
|
83
|
+
underline
|
84
|
+
puts "Wong: End of game! #{@next_song.name} is definitely not #{decision} than #{@current_song.name}".fg("#DC2D1E")
|
85
|
+
if decision == "higher" #user picked a decision of higher that is wrong. Next song would of been lower
|
86
|
+
puts "You choose higher"
|
87
|
+
current_song_info
|
88
|
+
next_song_info
|
89
|
+
puts "#{@next_song.name} is #{position_dif} places below"
|
90
|
+
else #user picked a decision of lower that is wrong. Next song would of been higher
|
91
|
+
puts "You choose lower"
|
92
|
+
next_song_info
|
93
|
+
current_song_info
|
94
|
+
puts "#{@next_song.name} is #{position_dif} places above"
|
95
|
+
end
|
96
|
+
|
97
|
+
puts "You got to level #{@level} for the year #{year}..."
|
98
|
+
puts ""
|
99
|
+
end
|
100
|
+
|
101
|
+
def answer_input
|
102
|
+
get_char
|
103
|
+
if @input == "h" || @input == "l"
|
104
|
+
round_logic
|
105
|
+
else
|
106
|
+
puts "Please answer with h for higher or l for lower"
|
107
|
+
answer_input
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def current_song_info
|
112
|
+
puts "#{@current_song.position}. #{@current_song.artist} - #{@current_song.name}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def next_song_info
|
116
|
+
puts "#{@next_song.position}. #{@next_song.artist} - #{@next_song.name}"
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assumption
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- DBuckley0126
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tco
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.8
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.8
|
97
|
+
description: A Command-line interface game which the user can select a year and play
|
98
|
+
assume if a song is higher or lower in the chart
|
99
|
+
email:
|
100
|
+
- dannyboy.msn@hotmail.com
|
101
|
+
executables:
|
102
|
+
- assumption
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- assumption.gemspec
|
115
|
+
- bin/assumption
|
116
|
+
- bin/console
|
117
|
+
- bin/setup
|
118
|
+
- config/environment.rb
|
119
|
+
- lib/assumption.rb
|
120
|
+
- lib/assumption/chart_data_set.rb
|
121
|
+
- lib/assumption/cli.rb
|
122
|
+
- lib/assumption/concerns/uni_functions.rb
|
123
|
+
- lib/assumption/data_importer.rb
|
124
|
+
- lib/assumption/game.rb
|
125
|
+
- lib/assumption/song.rb
|
126
|
+
- lib/assumption/version.rb
|
127
|
+
homepage: https://github.com/DBuckley0126/Assumption-CLI
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata:
|
131
|
+
allowed_push_host: https://rubygems.org
|
132
|
+
homepage_uri: https://github.com/DBuckley0126/CLI-Game-Assumption
|
133
|
+
source_code_uri: https://github.com/DBuckley0126/CLI-Game-Assumption
|
134
|
+
changelog_uri: https://github.com/DBuckley0126/CLI-Game-Assumption
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubygems_version: 3.0.6
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: 'Flatiron: CLI Scrapper Game'
|
154
|
+
test_files: []
|