Class: Print
- Inherits:
-
Object
- Object
- Defined in:
- lib/classes/Print.rb
Class Method Summary collapse
- .colorize_attribute(hash, key, type) ⇒ Object
- .print_pokemon_condensed(hash) ⇒ Object
- .print_pokemon_expanded(hash) ⇒ Object
Class Method Details
.colorize_attribute(hash, key, type) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/classes/Print.rb', line 34 def self.colorize_attribute(hash, key, type) attribute = '' hash.each do |k, v| attribute = v if k == key end case hash[type] when 'Normal' attribute when 'Fire' attribute.colorize(:red) when 'Water' attribute.colorize(:blue) when 'Grass' attribute.colorize(:green) when 'Electric' attribute.colorize(:light_blue) when 'Ice' attribute.colorize(:default) when 'Fighting' attribute.colorize(:light_red) when 'Poison' attribute.colorize(:cyan) when 'Ground' attribute.colorize(:default) when 'Flying' attribute.colorize(:light_white) when 'Psychic' attribute.colorize(:light_magenta) when 'Bug' attribute.colorize(:light_green) when 'Rock' attribute.colorize(:white) when 'Ghost' attribute.colorize(:light_black) when 'Dark' attribute.colorize(:black) when 'Dragon' attribute.colorize(:light_yellow) when 'Steel' attribute.colorize(:light_cyan) when 'Fairy' attribute.colorize(:magenta) end end |
.print_pokemon_condensed(hash) ⇒ Object
30 31 32 |
# File 'lib/classes/Print.rb', line 30 def self.print_pokemon_condensed(hash) puts colorize_attribute(hash, :name, :type_1) end |
.print_pokemon_expanded(hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/classes/Print.rb', line 7 def self.(hash) puts '-' * 40 puts (hash[:name]).to_s puts '-' * 40 print "#{hash[:name]} belongs to the #{colorize_attribute(hash, :type_1, :type_1)} type" if !hash[:type_2].nil? print ", with a secondary type of #{colorize_attribute(hash, :type_2, :type_2)} \n" else print ".\n" end puts "Total: #{hash[:total]}" puts "HP: #{hash[:hp]}" print "Attack: #{hash[:attack]} Defense :#{hash[:defense]}\n" print "Special Attack: #{hash[:"sp._atk"]} Special Defense: #{hash[:"sp._def"]}\n" puts "Speed: #{hash[:speed]}" puts "They are of Generation #{hash[:generation]}." if hash[:legendary] == 'True' puts "Most importantly, #{hash[:name]} is a legendary Pokemon!" end puts '-' * 40 Main_menu.return? end |