Class: MarvelCharactersCliGemEthel::CLI
- Inherits:
-
Object
- Object
- MarvelCharactersCliGemEthel::CLI
- Defined in:
- lib/marvel_characters_cli_gem_ethel/cli.rb
Instance Method Summary collapse
-
#build_character(input) ⇒ Object
Create Character.
- #call ⇒ Object
-
#print_character(input) ⇒ Object
Provide Detailed View of Selected Character.
- #select_another_character ⇒ Object
-
#start ⇒ Object
end call.
Instance Method Details
#build_character(input) ⇒ Object
Create Character
35 36 37 |
# File 'lib/marvel_characters_cli_gem_ethel/cli.rb', line 35 def build_character(input) MarvelCharactersCliGemEthel::Scraper.get_character_info(input) end |
#call ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/marvel_characters_cli_gem_ethel/cli.rb', line 3 def call puts "" puts "Get Some Interesting Information about the Top 10 Marvel Characters" puts "" main_page = MarvelCharactersCliGemEthel::Scraper.get_main_page count = 0 #Provide List View of Characters while count < 10 puts main_page.css('h3')[count].text count +=1 end start end |
#print_character(input) ⇒ Object
Provide Detailed View of Selected Character
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/marvel_characters_cli_gem_ethel/cli.rb', line 41 def print_character(input) acharacter = MarvelCharactersCliGemEthel::Characters puts "Super Name: #{acharacter.get_super_name}" puts "Real Name: #{acharacter.get_real_name}" puts "Character Type: #{acharacter.get_character_type}" puts "Number of Powers: #{acharacter.get_number_of_powers}" puts "List of Powers: " puts acharacter.get_list_of_powers.each{|one_power| puts one_power.to_s if one_power.to_s != "0"} puts "" puts '--------------------------------' end |
#select_another_character ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/marvel_characters_cli_gem_ethel/cli.rb', line 53 def select_another_character puts "" puts "Would you like to see another Marvel Character- Enter Y or N?" input2 = gets.strip.downcase if input2 == "y" call elsif input2 == "n" puts "" puts "Thank you for your time! Have a great day!" exit else puts "" puts "Invalid Entry - please try again." start end end |
#start ⇒ Object
end call
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/marvel_characters_cli_gem_ethel/cli.rb', line 21 def start puts "" puts "Please enter a number from 1 to 10." puts "" input = gets.strip.to_i-1 build_character(input) print_character(input) select_another_character end |