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
32
33
34
35
36
37
38
39
# File 'lib/top_ten_islands_cli_gem/cli.rb', line 16

def discription

  @input = 0
  #binding.pry
   until @input.to_i.between?(1,10) || @input == "list"
    puts " "
    puts "What number island would you like to read about? Or type list"
    @input = gets.chomp.downcase
  end

  if @input.to_i.between?(1,10)
    #binding.pry
    @input = @input.to_i
    puts ""
    puts "--------#{TopTenIslandsCliGem::Island.all[@input-1].name}--------"
    puts ""
    puts TopTenIslandsCliGem::Island.all[@input-1].get_discription
    puts ""
    ending
  elsif @input.downcase == "list"
    list
    discription
  end
end

#endingObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/top_ten_islands_cli_gem/cli.rb', line 41

def ending
  input = ""
  until input == "y" || input == "n" || input == "list"
    puts "Would you like to read about another island? Y,N or list"
    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!!"
    when "list"
      list
      discription
    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::Island.create_islands_from_hash
  puts " "
  puts "Welcome to the Worlds Top Islands to visit!!"
  puts " "
  list
  discription
end