pokedex-terminal 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 360fced44a71058bcaec8c07f2a57d3f8b9cb2330dfb55a072f5a7dde6ea0685
4
- data.tar.gz: 875cc3ace591042a18a1ce859c2f41a4b66585a9243866724a9266172f35629f
3
+ metadata.gz: 10da1af5c4625910694a802022db4675c81adba6e4c490256677dd4bba7eb98f
4
+ data.tar.gz: 83d8626e86fb96c0b0415d2a0e8c426cc71c30d476687d9d09e6c2bbcff8dccf
5
5
  SHA512:
6
- metadata.gz: 264dda2ae2c32b2313d881af00aeaad9082e249d0a5e7f37b96aba54fb540569d7022438dc8129fd6051713e3c89b63851685790dfd2301342f5e472077c2508
7
- data.tar.gz: c6655af403379e18d83c53caadf5e129a0b7f819b4cbe53dfad12a362696c76006ce19d2cca0d835c9cb0fa72dd29a74b1863fb997612b86d1603f21d6327bd7
6
+ metadata.gz: 824cf0ce804f60d950b2c1072770da11af84e337371ed2549eaafa1ac40bcc5d840207165d93f987ac1fd586c703ae0031a1b164a4d16176393b01be21261734
7
+ data.tar.gz: baf66dcb34a7daa5f3a1daab889a97a6a5d69a8fa5460c41112a6318f09a455c9b0bed47f256b848d74b178aa51b3c3eee400c87d2d05daff1d478bcf8efd741
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in pokedex-terminal.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pokedex-terminal (0.1.2)
4
+ pokedex-terminal (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,20 +1,53 @@
1
- # Pokedex::Terminal
1
+ # pokedex-terminal
2
2
 
3
- This terminal application seeks to emulate the basic functionality of the fictional ‘Pokedex’ device from within the Pokemon universe; a digital encyclopaedia of all existing Pokemon, their ‘Types’ and their attributes.
3
+ This terminal application seeks to emulate the basic functionality of the fictional ‘Pokedex’ device from within the Pokemon universe; a digital encyclopaedia of all existing Pokemon, their ‘Types’ and their attributes. Unlike the classical Pokedex, the user is able to update attributes of any Pokemon and add an entirely new Pokemon of their choosing to the database.
4
4
 
5
- While several Pokedex applications exist, pokedex-terminal seeks to run with minimal computational resources as to allow access to the widest audience possible, particuarly those using outdated devices.
5
+ While several Pokedex applications exist, pokedex-terminal seeks to run with *minimal computational resources* as to allow access to the widest audience possible, particuarly those using outdated devices.
6
6
 
7
- pokedex-terminal also allows offline access to Pokemon attributes and descriptions for usage in situations where there is no internet access, or if Pokemon-related online content has been blocked/censored under oppressive regimes.
7
+ pokedex-terminal also allows offline access to Pokemon attributes and descriptions for usage in situations where there is no internet access, or if Pokemon-related online content has been blocked/censored under oppressive regimes where downloading or accessing Pokemon-related online content is ***punishable by death***.
8
+
9
+ ---
10
+
11
+ ## Links
12
+ - [pokedex-terminal Github Repository](https://github.com/novacoole/pokedex-terminal)
13
+ - [pokedex-terminal RubyGem Repository](https://rubygems.org/gems/pokedex-terminal)
14
+
15
+ ---
16
+
17
+ ## Tests
18
+
19
+ I used manual testing to test my app. You can find a spreadsheet that documents these tests [here.](https://ethercalc.org/1joas16280u9)
20
+
21
+ ---
8
22
 
9
23
  ## Installation
10
24
 
25
+ You will need ruby installed to use this application.
26
+ Once you have, run the command below from terminal.
11
27
  ```
12
28
  $ gem install pokedex-terminal
13
29
  ```
30
+ #### Dependencies
31
+
32
+ * [artii](https://github.com/miketierney/artii)
33
+ * [colorize](https://github.com/fazibear/colorize)
34
+ * [lolcat](https://github.com/busyloop/lolcat/)
35
+ * [smarter_csv](https://github.com/tilo/smarter_csv)
36
+ * [tty-prompt](https://github.com/piotrmurach/tty-prompt#32-active_color)
37
+
38
+ #### Hardware requirements.
39
+
40
+ This program should run on any terminal-enabled device built during or after the year that the Pokemon franchise was created.
41
+
42
+ ---
14
43
 
15
44
  ## Usage
16
45
 
17
- TODO: Write usage instructions here
46
+ Run in terminal.
47
+ ```
48
+ $ pokemon-terminal
49
+ ```
50
+ ---
18
51
 
19
52
  ## Features
20
53
 
@@ -24,11 +57,11 @@ This application allows the user to do the following:
24
57
 
25
58
  When the user selects "List Pokemon" from the main menu, the list_menu method of the List class is called. This method contains a menu system derived from 'tty-prompt' gem. This menu offers several options:
26
59
 
27
- 1. "List all"
60
+ 1. **"List all"**
28
61
 
29
62
  To List all pokemon, the .list_all method of the List class is called. This method takes an input of data (@@pokemon_data). Then, a .each loop to iterate through the @@pokemon_data object (which contains hashes for each Pokemon). For each hash, the .print_pokemon_condensed method of the Print class is called with that hash an input. This method prints only the ':name' value of that hash.
30
63
 
31
- 2. "List by Type"
64
+ 2. **"List by Type"**
32
65
 
33
66
  To list Pokemon by type, firstly the .add_type method belonging to the New class is called. This presents the user with a 'tty-prompt' .select menu which allows them to select a Pokemon Type. The user choice is returned and stored in the 'user_input' variable.
34
67
 
@@ -36,15 +69,15 @@ When the user selects "List Pokemon" from the main menu, the list_menu method of
36
69
 
37
70
  This method uses a .each method to iterate through each hash the @@pokemon_data object, if a hash's ':type_1' value matches user_input, the .print_pokemon_condensed method of the Print class is called with that hash an input. This method prints only the ':name' value of that hash.
38
71
 
39
- 3. "List by Secondary Type"
72
+ 3. **"List by Secondary Type"**
40
73
 
41
- To list Pokemon by type, firstly the .add_type method belonging to the New class is called. This presents the user with a 'tty-prompt' .select menu which allows them to select a Pokemon Secondary Type. The user choice is returned and stored in the 'user_input' variable.
74
+ To list Pokemon by type, firstly the .add_type method belonging to the New class is called. This presents the user with a 'tty-prompt' .select menu which allows them to select a Pokemon Secondary Type. The user choice is returned and stored in the 'user_input' variable.
42
75
 
43
76
  Then the .list_by method of the List class is called. This method takes an input of data (@@pokemon_data), the hash key we want to filter within (:type_2), and the exact value we want to filter (user_input).
44
77
 
45
78
  This method uses a .each method to iterate through each hash the @@pokemon_data object, if a hash's ':type_2' value matches user_input, the .print_pokemon_condensed method of the Print class is called with that hash an input. This method prints only the ':name' value of that hash.
46
79
 
47
- 4. "List by Generation"
80
+ 4. **"List by Generation"**
48
81
 
49
82
  To list Pokemon by generation, firstly a 'tty-prompt' ..ask method is used to prompt the user for a number between 1-8. This input is returned and stored in a variable called 'user_input.
50
83
 
@@ -53,7 +86,7 @@ When the user selects "List Pokemon" from the main menu, the list_menu method of
53
86
  This method uses a .each method to iterate through each hash the @@pokemon_data object, if a hash's ':generation' value matches user_input, the .print_pokemon_condensed method of the Print class is called with that hash an input. This method prints only the ':name' value of that hash.
54
87
 
55
88
 
56
- 5. "List Legendary Pokemon"
89
+ 5. **"List Legendary Pokemon"**
57
90
 
58
91
  To list Pokemon by generation, the .list_by method of the List class is called. This method takes an input of data (@@pokemon_data), the hash key we want to filter within (:legendary), and the exact value we want to filter ('True').
59
92
 
@@ -63,19 +96,26 @@ When the user selects "List Pokemon" from the main menu, the list_menu method of
63
96
 
64
97
  ## Development
65
98
 
66
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
99
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests (**if they exist**). You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
100
 
68
101
  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).
69
102
 
103
+ ---
104
+
70
105
  ## Contributing
71
106
 
72
107
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pokedex-terminal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/pokedex-terminal/blob/master/CODE_OF_CONDUCT.md).
73
108
 
109
+ ---
74
110
 
75
111
  ## License
76
112
 
77
113
  The gem is available as open source under the terms of the [GPL-3.0 License](https://opensource.org/licenses/GPL-3.0).
78
114
 
115
+ ---
116
+
79
117
  ## Code of Conduct
80
118
 
81
- Everyone interacting in the Pokedex::Terminal project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pokedex-terminal/blob/master/CODE_OF_CONDUCT.md).
119
+ Everyone interacting in the pokedex-terminal project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pokedex-terminal/blob/master/CODE_OF_CONDUCT.md).
120
+
121
+ ---
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "terminal"
4
+ require 'bundler/setup'
5
+ require 'terminal'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "terminal"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/bin/pokedex-terminal CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require_relative "../lib/pokedex-terminal"
4
+ require 'pokedex-terminal'
@@ -1,30 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # this class handles delete functionality by iterating through our data until we match with user's selected pokemon date, and then deleting the entire hash.
4
+
1
5
  require 'tty-prompt'
2
6
  require_relative './Main_menu'
3
7
 
4
8
  class Delete
5
-
6
9
  def self.delete(data)
7
10
  delete_prompt = TTY::Prompt.new(active_color: :red)
8
- poke_array = []
9
- data.each do |hash|
10
- hash.each do |k,v|
11
- if k == :name
12
- poke_array << v
13
- end
14
- end
15
- end
16
- user_input = delete_prompt.select('Please enter the name of the Pokemon you\'re looking to delete', poke_array, filter: true)
17
- data.each_with_index do |hash, index|
18
- if hash[:name] == user_input
19
- user_input_2 = delete_prompt.yes?("Are you sure you want to permanently delete #{hash[:name]}?")
20
- if user_input_2 == true
21
- data.delete_at(index)
22
- return data
23
- else
24
- Main_menu.run
25
- end
26
- end
11
+ user_input Search.by_name(data)
12
+ data.each_with_index do |hash, index|
13
+ next unless hash[:name] == user_input
14
+
15
+ user_input_2 = delete_prompt.yes?("Are you sure you want to permanently delete #{hash[:name]}?")
16
+ if user_input_2 == true
17
+ data.delete_at(index)
18
+ return data
19
+ else
20
+ Main_menu.run
27
21
  end
22
+ end
28
23
  end
29
-
30
- end
24
+ end
data/lib/classes/List.rb CHANGED
@@ -1,53 +1,58 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tty-prompt'
2
4
 
3
5
  class List
4
-
5
6
  def self.list_menu(data)
6
- while true
7
- system 'clear'
7
+ loop do
8
8
  list_prompt = TTY::Prompt.new(active_color: :red)
9
9
  user_input = list_prompt.select("How would you like to list the Pokemon?\nPlease enter one of the following options.") do |menu|
10
- menu.choice "List all", 1
11
- menu.choice "List by Type", 2
12
- menu.choice "List by Secondary Type",3
13
- menu.choice "List by Generation", 4
14
- menu.choice "List Legendary Pokemon", 5
10
+ menu.choice 'List all', 1
11
+ menu.choice 'List by Type', 2
12
+ menu.choice 'List by Secondary Type', 3
13
+ menu.choice 'List by Generation', 4
14
+ menu.choice 'List Legendary Pokemon', 5
15
15
  end
16
16
  case user_input
17
- when 1
18
- puts "-" * 40
19
- puts "Listing all Pokemon"
20
- puts "-" * 40
21
- list_all(data)
22
- when 2
23
- puts "Which Type would you like to list by?"
24
- user_input = New.add_type
25
- puts "-" * 40
26
- puts "Listing by #{user_input} Type:"
27
- puts "-" * 40
28
- list_by(data,:type_1,user_input)
29
- when 3
30
- puts "Which Secondary Type would you like to list by?"
31
- user_input = New.add_type
32
- puts "-" * 40
33
- puts "Listing by #{user_input} Secondary Type:"
34
- puts "-" * 40
35
- list_by(data,:type_2,user_input)
36
- when 4
37
- while true
38
- user_input = list_prompt.ask("Which generation would you like to list by?\nInput a number between 1-8.") { |q| q.in('1-8') }
39
- puts "-" * 40
40
- puts "Listing by Generation #{user_input}"
41
- puts "-" * 40
42
- list_by(data,:generation, user_input.to_i)
43
- end
44
- when 5
45
- puts "-" * 40
46
- puts "Listing Legendary Pokemon"
47
- puts "-" * 40
48
- list_by(data,:legendary,'True')
49
- else
50
- puts "Invalid selection, please enter a number between 1-5."
17
+ when 1
18
+ puts '-' * 40
19
+ puts 'Listing all Pokemon'
20
+ puts '-' * 40
21
+ list_all(data)
22
+ Main_menu.return?
23
+ when 2
24
+ puts 'Which Type would you like to list by?'
25
+ user_input = New.add_type
26
+ puts '-' * 40
27
+ puts "Listing by #{user_input} Type:"
28
+ puts '-' * 40
29
+ list_by(data, :type_1, user_input)
30
+ Main_menu.return?
31
+ when 3
32
+ puts 'Which Secondary Type would you like to list by?'
33
+ user_input = New.add_type
34
+ puts '-' * 40
35
+ puts "Listing by #{user_input} Secondary Type:"
36
+ puts '-' * 40
37
+ list_by(data, :type_2, user_input)
38
+ Main_menu.return?
39
+ when 4
40
+ loop do
41
+ user_input = list_prompt.ask("Which generation would you like to list by?\nInput a number between 1-8.") { |q| q.in('1-8') }
42
+ puts '-' * 40
43
+ puts "Listing by Generation #{user_input}"
44
+ puts '-' * 40
45
+ list_by(data, :generation, user_input.to_i)
46
+ Main_menu.return?
47
+ end
48
+ when 5
49
+ puts '-' * 40
50
+ puts 'Listing Legendary Pokemon'
51
+ puts '-' * 40
52
+ list_by(data, :legendary, 'True')
53
+ Main_menu.return?
54
+ else
55
+ puts 'Invalid selection, please enter a number between 1-5.'
51
56
  end
52
57
  end
53
58
  end
@@ -56,19 +61,15 @@ class List
56
61
  data.each do |hash|
57
62
  Print.print_pokemon_condensed(hash)
58
63
  end
59
- puts "-" * 40
60
- Main_menu.return?
64
+ puts '-' * 40
65
+ Main_menu.return?
61
66
  end
62
67
 
63
- def self.list_by(data,attribute,value)
68
+ def self.list_by(data, attribute, value)
64
69
  data.each do |hash|
65
- if hash[attribute] == value
66
- Print.print_pokemon_condensed(hash)
67
- end
70
+ Print.print_pokemon_condensed(hash) if hash[attribute] == value
68
71
  end
69
- puts "-" * 40
70
- Main_menu.return?
72
+ puts '-' * 40
73
+ Main_menu.return?
71
74
  end
72
-
73
75
  end
74
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './Search'
2
4
  require_relative './Update'
3
5
  require_relative './New'
@@ -9,62 +11,91 @@ require 'artii'
9
11
  require 'lolize'
10
12
 
11
13
  class Main_menu
12
- @@pokemon_data = SmarterCSV.process('../../data/pokemon.csv')
14
+ # Creates an array of hashes from the CSV file with keys taken from CSV headers.
15
+ @@pokemon_data = SmarterCSV.process(File.dirname(__FILE__) + '/pokemon.csv')
13
16
 
14
17
  def self.run
15
- while true
16
- fork{exec "artii './titlesequence.plaintext' --font larry3d | lolcat"}
18
+ loop do
19
+ system 'clear'
20
+ sleep 0.1
21
+ fork { exec "artii 'Pokedex' --font larry3d | lolcat" }
22
+ sleep(0.3)
17
23
  main_menu_prompt = TTY::Prompt.new(active_color: :red)
18
- puts "-" * 40
19
- puts " Welcome to your Pokedex! ".blue.on_red.blink
20
- puts "-" * 40
21
- user_input = main_menu_prompt.select("Please select from the following:") do |menu|
22
- menu.choice 'List Pokemon', 1
23
- menu.choice 'Search for a Pokemon', 2
24
- menu.choice 'Update an existing Pokemon', 3
25
- menu.choice 'Add a new Pokemon', 4
26
- menu.choice 'Delete a Pokemon', 5
27
- menu.choice 'Exit', 6
28
- menu.choice 'Print hashes', 7
24
+ puts '-' * 40
25
+ puts ' Welcome to your Pokedex! '.blue.on_red.blink
26
+ puts '-' * 40
27
+ user_input = main_menu_prompt.select('Please select from the following:') do |menu|
28
+ menu.choice 'List Pokemon', 1
29
+ menu.choice 'Search for a Pokemon', 2
30
+ menu.choice 'Update an existing Pokemon', 3
31
+ menu.choice 'Add a new Pokemon', 4
32
+ menu.choice 'Delete a Pokemon', 5
33
+ menu.choice 'Exit and save changes', 6
34
+ # menu.choice 'Print hashes', 7
29
35
  end
30
36
  case user_input
31
- when 1
32
-
33
- List.list_menu(@@pokemon_data)
34
- when 2
35
- name = Search.by_name(@@pokemon_data)
36
- hash = Search.return_hash(@@pokemon_data, name)
37
- Print.print_pokemon_expanded(hash)
38
- when 3
39
- Update.update_pokemon_menu(@@pokemon_data)
40
- ## Incomplete
41
- when 4
42
- new_hash = New.add_pokemon
43
- @@pokemon_data << new_hash
44
- Print.print_pokemon_expanded(new_hash)
45
- when 5
46
- @@pokemon_data = Delete.delete(@@pokemon_data)
47
- when 6
48
- CSV.open('../../data/pokemon.csv', "wb") do |csv|
49
- keys = @@pokemon_data.first.keys
50
- csv << keys
51
- @@pokemon_data.each do |hash|
52
- csv << hash.values_at(*keys)
53
- end
54
- end
55
- exit
56
- when 7
57
- pp @@pokemon_data
58
- else
59
- "Invalid selection, please select from the following options."
37
+ when 1
38
+ list_pokemon
39
+ when 2
40
+ search_pokemon
41
+ when 3
42
+ update_pokemon
43
+ when 4
44
+ new_pokemon
45
+ when 5
46
+ delete_pokemon
47
+ when 6
48
+ exit_menu
49
+ # uncomment below 2 lines to allow developer feature to check hashes
50
+ # when 7
51
+ # pp @@pokemon_data
52
+ else
53
+ 'Invalid selection, please select from the following options.'
60
54
  end
61
55
  end
62
56
  end
63
57
 
64
58
  def self.return?
65
- puts "Press enter to return to the Main Menu."
59
+ puts 'Press enter to return to the Main Menu.'
66
60
  user_input = gets.chomp
67
- run()
61
+ run
62
+ end
63
+
64
+ def self.list_pokemon
65
+ List.list_menu(@@pokemon_data)
66
+ end
67
+
68
+ def self.search_pokemon
69
+ Print.print_pokemon_expanded(Search.return_hash(@@pokemon_data, Search.by_name(@@pokemon_data)))
70
+ end
71
+
72
+ def self.update_pokemon
73
+ Update.update_pokemon_menu(@@pokemon_data)
68
74
  end
69
75
 
70
- end
76
+ def self.new_pokemon
77
+ new_hash = New.add_pokemon
78
+ @@pokemon_data << new_hash
79
+ Print.print_pokemon_expanded(new_hash)
80
+ end
81
+
82
+ def self.delete_pokemon
83
+ @@pokemon_data = Delete.delete(@@pokemon_data)
84
+ end
85
+
86
+ def self.exit_menu
87
+ save_changes = main_menu_prompt.ask('Are you sure you want to save your changes?')
88
+ if save_changes == true
89
+ CSV.open(File.dirname(__FILE__) + '/pokemon.csv', 'wb') do |csv|
90
+ keys = @@pokemon_data.first.keys
91
+ csv << keys
92
+ @@pokemon_data.each do |hash|
93
+ csv << hash.values_at(*keys)
94
+ end
95
+ end
96
+ exit
97
+ else
98
+ exit
99
+ end
100
+ end
101
+ end
data/lib/classes/New.rb CHANGED
@@ -1,20 +1,22 @@
1
- class New
1
+ # frozen_string_literal: true
2
2
 
3
+ class New
3
4
  def self.add_pokemon
4
- puts "So you want to create a new Pokemon, what will you call it?"
5
- name = add_name()
6
- puts "What type will your Pokemon belong to?"
7
- type_1 = add_type()
8
- puts "Now for the secondary type."
9
- type_2 = add_type()
5
+ puts 'So you want to create a new Pokemon, what will you call it?'
6
+ name = add_name
7
+ puts 'What type will your Pokemon belong to?'
8
+ type_1 = add_type
9
+ puts 'Now for the secondary type.'
10
+ type_2 = add_type
10
11
  hp = add_points('HP')
11
12
  attack = add_points('Attack')
12
13
  defense = add_points('Defense')
13
14
  sp_atk = add_points('Special Attack')
14
15
  sp_def = add_points('Special Defense')
15
16
  speed = add_points('Speed')
16
- generation = add_generation()
17
- legendary = add_legendary()
17
+ generation = add_generation
18
+ legendary = add_legendary
19
+ p legendary
18
20
  total = hp + attack + sp_atk + sp_def + speed
19
21
  hash = {}
20
22
  hash[:name] = name
@@ -29,50 +31,48 @@ class New
29
31
  hash[:speed] = speed
30
32
  hash[:generation] = generation
31
33
  hash[:legendary] = legendary
32
- pp hash
33
- return hash
34
+ hash
34
35
  end
35
36
 
36
-
37
37
  def self.add_name
38
- print "> "
39
- return gets.chomp
38
+ print '> '
39
+ gets.chomp
40
40
  end
41
41
 
42
42
  def self.add_type
43
43
  new_prompt = TTY::Prompt.new(active_color: :red)
44
- user_input = new_prompt.select("Please select a Type.") do |menu|
45
- menu.choice "Normal"
46
- menu.choice "Fire"
47
- menu.choice "Water"
48
- menu.choice "Grass"
49
- menu.choice "Electric"
50
- menu.choice "Ice"
51
- menu.choice "Fighting"
52
- menu.choice "Poison"
53
- menu.choice "Ground"
54
- menu.choice "Flying"
55
- menu.choice "Psychic"
56
- menu.choice "Bug"
57
- menu.choice "Rock"
58
- menu.choice "Ghost"
59
- menu.choice "Dark"
60
- menu.choice "Dragon"
61
- menu.choice "Steel"
62
- menu.choice "Fairy"
44
+ user_input = new_prompt.select('Please select a Type.') do |menu|
45
+ menu.choice 'Normal'
46
+ menu.choice 'Fire'
47
+ menu.choice 'Water'
48
+ menu.choice 'Grass'
49
+ menu.choice 'Electric'
50
+ menu.choice 'Ice'
51
+ menu.choice 'Fighting'
52
+ menu.choice 'Poison'
53
+ menu.choice 'Ground'
54
+ menu.choice 'Flying'
55
+ menu.choice 'Psychic'
56
+ menu.choice 'Bug'
57
+ menu.choice 'Rock'
58
+ menu.choice 'Ghost'
59
+ menu.choice 'Dark'
60
+ menu.choice 'Dragon'
61
+ menu.choice 'Steel'
62
+ menu.choice 'Fairy'
63
63
  end
64
- return user_input
64
+ user_input
65
65
  end
66
66
 
67
67
  def self.add_points(attribute)
68
- while true
68
+ loop do
69
69
  puts "How many points would you like this Pokemon to have for #{attribute}?"
70
- print "> "
70
+ print '> '
71
71
  user_input = gets.chomp.to_i
72
72
  if user_input > 0
73
73
  return user_input
74
74
  else
75
- puts "Invalid selection. Please input a number greater than 0."
75
+ puts 'Invalid selection. Please input a number greater than 0.'
76
76
  end
77
77
  end
78
78
  end
@@ -80,10 +80,10 @@ class New
80
80
  def self.add_generation
81
81
  new_prompt = TTY::Prompt.new(active_color: :red)
82
82
  user_input = new_prompt.ask("Which generation does this Pokemon belong to?\nInput a number between 1-8.") do |q|
83
- q.in('1-8')
83
+ q.in('1-8')
84
84
  q.messages[:valid?] = 'Invalid number, select a number from 1-8'
85
85
  end
86
- return user_input
86
+ user_input
87
87
  end
88
88
 
89
89
  def self.add_legendary
@@ -92,7 +92,6 @@ class New
92
92
  q.messages[:valid?] = "Invalid response, select 'Y' or 'n'"
93
93
  end
94
94
  p user_input
95
- return user_input = true ? 'True' : 'False'
95
+ user_input == true ? 'True' : 'False'
96
96
  end
97
-
98
- end
97
+ end