lib/nswparks/cli.rb
# Puts out a list of National Parks in a selected NSW Region
Puts out a list of National Parks in a selected NSW Region
Puts out a list of National Parks in a selected NSW Region
def park_region
    region_no = 0
    park_no = 0
    puts ""
    areas = NSWParks::Nsw_regions.nsw_regions  
    puts ""
    puts "Enter the number for the region you are interested in:"
    region_no = gets.strip.to_i 
    while !(region_no.is_a? Integer) || region_no < 1 || region_no > areas.size
      puts ""
      NSWParks::Nsw_regions.nsw_regions
      region_no = NSWParks::Nsw_parks.valid_input?
    end
    puts ""
    puts "The parks in the #{areas[region_no.to_i - 1]} region are:"
    array = NSWParks::Nsw_regions.park_region(region_no.to_s)
    array.each.with_index(1) {|region,i| puts "#{i}. #{region}"} 
    puts ""
    puts "Enter your park number from this list for more information:"
    park_no = gets.strip.to_i 
    while !(park_no.is_a? Integer) || park_no < 1 || park_no > array.size
      array = NSWParks::Nsw_regions.park_region(region_no.to_s)
      array.each.with_index(1) {|region,i| puts "#{i}. #{region}"}
      park_no = NSWParks::Nsw_parks.valid_input?
    end
    puts ""
    puts "Information for #{array[park_no - 1]}:"  
    puts "----------------------------------------------------------------------------------------"
    NSWParks::Nsw_parks.park_from_region(array[park_no - 1])  
  end
def park_region region_no = 0 park_no = 0 puts "" areas = NSWParks :: Nsw_regions . nsw_regions puts "" puts "Enter the number for the region you are interested in:" region_no = gets . strip . to_i while ! ( region_no . is_a? Integer ) || region_no < 1 || region_no > areas . size puts "" NSWParks :: Nsw_regions . nsw_regions region_no = NSWParks :: Nsw_parks . valid_input? end puts "" puts "The parks in the #{areas[region_no.to_i - 1]} region are:" array = NSWParks :: Nsw_regions . park_region ( region_no . to_s ) array . each . with_index ( 1 ) { | region , i | puts "#{i}. #{region}" } puts "" puts "Enter your park number from this list for more information:" park_no = gets . strip . to_i while ! ( park_no . is_a? Integer ) || park_no < 1 || park_no > array . size array = NSWParks :: Nsw_regions . park_region ( region_no . to_s ) array . each . with_index ( 1 ) { | region , i | puts "#{i}. #{region}" } park_no = NSWParks :: Nsw_parks . valid_input? end puts "" puts "Information for #{array[park_no - 1]}:" puts "----------------------------------------------------------------------------------------" NSWParks :: Nsw_parks . park_from_region ( array [ park_no - 1 ] ) end
Puts out a list of National Parks in a selected NSW Region
Puts out a list of National Parks in a selected NSW Region
# Use #park_area to output list of NSW Regions and select a region # Validate user input - input must be numerical and exist in the list    # Puts parks in region using Nsw_parks # Validate user input - input must be numerical and exist in the list   # Puts out heading of park name # Puts out parks info using Nsw_parks #park_from_region to locate park in @@all