pokemoves-cli 1.0.7 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 732a8a1db9efc35c555d6588a28345acf413bdcb0be669dbcd6be9214029a5a1
4
- data.tar.gz: a364a2d42b880891dbddd5f09216d22e123ee963e4f90325213dec0eb03d70f0
3
+ metadata.gz: cb8cb7108327718cdb80a49954b547282c2590b999398e33d22767a76aab9956
4
+ data.tar.gz: 03077af2c10f6cb231417002d5d9c9dc514f35327cc66b7878893e06351bc28b
5
5
  SHA512:
6
- metadata.gz: 6c04dcacf11cf91b75b4532b4b8cbe52badcab43eed1a899820020046f2f563bc69f65e277863b2b48988a3dd2d8db3c8e4f774bfb7ffcc5a87c0f32b6272879
7
- data.tar.gz: f7799aa935a3ca46686efa9586557d7b0eb2e94d70ccdd0573426aff5f4075cf067748e7ab602e91a48bdde12bb143d8dd271c875e1f415a3471b8a1739d8189
6
+ metadata.gz: 83475f7b57df6097d9616451b67d44a9a019c1306ffa804a62a0ca56282eb10dcd7c16e4ddfc51481f9348dfd5a8915f335bc764e9e83b21b806db634ec878d3
7
+ data.tar.gz: 44624204c1f2c53f05f812d97790949175f0a3456cb97e4aa5a90a5c68c02520b98a69ad8bbd45bc21d4f24ea3d2006cde46c56012b0f624c8a1250d851dd3a7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pokemoves-cli (1.0.7)
4
+ pokemoves-cli (1.0.8)
5
5
  httparty
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
- <<<<<<< HEAD
2
1
  # Pokemoves-cli
3
2
 
4
3
  Pokemoves allows you to easily check which moves pokemon can learn, as well as which pokemon can learn a specific move. You can also check a move's given type.
@@ -2,15 +2,23 @@ require_relative "scraper.rb"
2
2
  require_relative "pokemon.rb"
3
3
 
4
4
  class Move
5
- attr_reader :name, :type
5
+ attr_reader :name, :pretty_name
6
6
  @@all = []
7
7
 
8
8
  def initialize(name)
9
9
  @name = name
10
- @type = Scraper.get_move_by_name(name)["type"]["name"]
10
+ @pretty_name = name.split("-").collect{|word| word.capitalize}.join(" ")
11
+
11
12
  @@all << self
12
13
  end
13
14
 
15
+ def type
16
+ if @type == nil
17
+ @type = Scraper.get_move_by_name(name)["type"]["name"]
18
+ end
19
+ @type
20
+ end
21
+
14
22
  def self.all
15
23
  @@all
16
24
  end
@@ -22,4 +30,8 @@ class Move
22
30
  end
23
31
  return nil
24
32
  end
33
+
34
+ def self.find_or_create_by_pretty_name(pretty_name)
35
+ self.find_or_create_by_name(pretty_name.split(" ").collect{|word| word.downcase}.join("-"))
36
+ end
25
37
  end
@@ -11,11 +11,11 @@ class Pokemon
11
11
  end
12
12
 
13
13
  def get_moves
14
- moves = Scraper.get_pokemon_by_name(@name)["moves"].collect{|move_hash| move_hash["move"]["name"]}
14
+ moves = Scraper.get_pokemon_by_name(@name)["moves"].collect{|move_hash| Move.new(move_hash["move"]["name"])}
15
15
  end
16
16
 
17
- def can_learn_move?(move_name)
18
- self.get_moves.include?(move_name)
17
+ def can_learn_move?(move)
18
+ self.get_moves.collect{|m| m.name}.include?(move.name)
19
19
  end
20
20
 
21
21
  def self.all
@@ -24,7 +24,7 @@ require "pokemoves/cli/version"
24
24
  gets
25
25
  counter = 1
26
26
  current_pokemon.get_moves.each{|move|
27
- puts "#{counter}. #{move.split("-").collect{|word| word.capitalize}.join(" ")}"
27
+ puts "#{counter}. #{move.pretty_name}"
28
28
  counter += 1
29
29
  }
30
30
  puts "Enter the number of the move you'd like to know the type of."
@@ -32,8 +32,8 @@ require "pokemoves/cli/version"
32
32
  num = gets.to_i
33
33
  until num <= 0
34
34
  if(num <= current_pokemon.get_moves.size)
35
- current_move = Move.find_or_create_by_name(current_pokemon.get_moves[num - 1])
36
- puts "The move #{current_move.name.capitalize} is a #{current_move.type} type move."
35
+ current_move = Move.find_or_create_by_name(current_pokemon.get_moves[num - 1].name)
36
+ puts "The move #{current_move.pretty_name} is a #{current_move.type} type move."
37
37
  else
38
38
  puts "That number is not in the list of moves."
39
39
  end
@@ -45,13 +45,13 @@ require "pokemoves/cli/version"
45
45
  elsif input == 2
46
46
  puts "Enter the name of a move!"
47
47
  move_name = gets.chomp
48
- until Move.find_or_create_by_name(move_name.split(" ").collect{|word| word.downcase}.join("-")) != nil
48
+ until Move.find_or_create_by_pretty_name(move_name) != nil
49
49
  puts "It doesn't look like we have that move stored."
50
50
  puts "Try a different one."
51
51
  move_name = gets.chomp
52
52
  end
53
- current_move = Move.find_or_create_by_name(move_name.split(" ").collect{|word| word.downcase}.join("-"))
54
- puts "Enter the name of a pokemon to see if they can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}"
53
+ current_move = Move.find_or_create_by_pretty_name(move_name)
54
+ puts "Enter the name of a pokemon to see if they can learn #{current_move.pretty_name}"
55
55
  pokemon_name = gets.chomp
56
56
  until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil
57
57
  puts "It doesn't look like we have that pokemon stored."
@@ -60,12 +60,12 @@ require "pokemoves/cli/version"
60
60
  end
61
61
  until pokemon_name == "exit"
62
62
  current_pokemon = Pokemon.find_or_create_by_name(pokemon_name.downcase)
63
- if current_pokemon.can_learn_move?(current_move.name)
64
- puts "It looks like #{current_pokemon.name.capitalize} can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
63
+ if current_pokemon.can_learn_move?(current_move)
64
+ puts "It looks like #{current_pokemon.name.capitalize} can learn #{current_move.pretty_name}."
65
65
  else
66
- puts "It looks like #{current_pokemon.name.capitalize} can't learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
66
+ puts "It looks like #{current_pokemon.name.capitalize} can't learn #{current_move.pretty_name}."
67
67
  end
68
- puts "Enter the name of another pokemon to see if they can learn #{current_move.name.split("-").collect{|word| word.capitalize}.join(" ")}."
68
+ puts "Enter the name of another pokemon to see if they can learn #{current_move.pretty_name}."
69
69
  puts "Enter \"exit\" to continue to the main menu."
70
70
  pokemon_name = gets.chomp
71
71
  until Pokemon.find_or_create_by_name(pokemon_name.downcase) != nil || pokemon_name == "exit"
@@ -1,5 +1,5 @@
1
1
  module Pokemoves
2
2
  module Cli
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pokemoves-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Andrew Ribas'"