Class: TopTenIslandsCliGem::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/top_ten_islands_cli_gem/cli.rb

Instance Method Summary collapse

Instance Method Details

#discriptionObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/top_ten_islands_cli_gem/cli.rb', line 16

def discription
  @input = 0
  #binding.pry
  until @input.between?(1,10)
    puts " "
    puts "What number island would you like to read about?"
    @input = gets.chomp.to_i
  end
  #binding.pry
  puts ""
  puts "--------#{TopTenIslandsCliGem::Island.all[@input-1].name}--------"
  puts ""
  puts TopTenIslandsCliGem::Island.all[@input-1].get_discription
  puts ""
  ending
end

#endingObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/top_ten_islands_cli_gem/cli.rb', line 33

def ending
  input = ""
  until input == "y" || input == "n"
    puts "Would you like to read about another island? Y or N"
    input = gets.chomp.downcase
  end
    case input
    when  "y"
      discription
    when  "n"
      puts "Hope to see you at #{TopTenIslandsCliGem::Island.all[@input-1].name} soon!!"
    end

end

#listObject



12
13
14
# File 'lib/top_ten_islands_cli_gem/cli.rb', line 12

def list
  TopTenIslandsCliGem::Island.all.each.with_index(1) {|island, index| puts "#{index}. #{island.name}"}
end

#startObject



3
4
5
6
7
8
9
10
# File 'lib/top_ten_islands_cli_gem/cli.rb', line 3

def start
  TopTenIslandsCliGem::Scraper.create_islands
  puts " "
  puts "Welcome to the Worlds Top Islands to visit!!"
  puts " "
  list
  discription
end