Class: Api

Inherits:
Object
  • Object
show all
Defined in:
lib/FreeWiFiNYC/api.rb

Class Method Summary collapse

Class Method Details

.neighborhoodObject

attr_accessor :borough_name, :neighborhood_name



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/FreeWiFiNYC/api.rb', line 5

def self.neighborhood
  puts "This is a list of the Wifi locations by neighborhood in #{Cli.borough_name}.\n"
  neighborhood_array = []
  Scraper.all_data.each do |each_entry|
    if each_entry["boroname"] == Cli.borough_name
        neighborhood_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
        neighborhood_array << neighborhood_list unless neighborhood_array.include?(neighborhood_list)
      end #if
  end #do
  puts neighborhood_array.sort
  Cli.search_again_met
end

.neighborhood_listObject



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
# File 'lib/FreeWiFiNYC/api.rb', line 39

def self.neighborhood_list
  puts "Please select a #{@borough} neighborhood."
  neighborhood_array = []
  neighboorhood_hash = Hash.new
  Scraper.all_data.each do |each_entry|
    if each_entry["boroname"] == Cli.borough_name
    neighborhood_list = "#{each_entry["ntaname"]}"
    neighborhood_array << neighborhood_list unless neighborhood_array.include?(neighborhood_list)
    end #if
  end #do
    neighborhood_array.sort.each.with_index(1) do |neighborhood,i|
    puts "#{i} - #{neighborhood}"
    neighboorhood_hash[i] = neighborhood
    end #do
  puts "\nPlease select a neighborhood to search."
    neighborhood_search = gets.chomp.upcase
  Scraper.all_data.each do |each_entry|
    neighborhood_list_array = []
    if each_entry["ntaname"] == neighboorhood_hash[neighborhood_search.to_i]
      neighborhood_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
      neighborhood_list_array << neighborhood_list unless neighborhood_list_array.include?(neighborhood_list)
      end#if
      puts neighborhood_list_array.sort
  end #do
  Cli.search_again_met
end

.zip_codeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/FreeWiFiNYC/api.rb', line 18

def self.zip_code
  puts "\nSearching for WiFi in zip code: #{Cli.find_wifi_input}\n\n"
  puts "\n.\n"
  puts "..."
  puts "....."
  puts "......."
  puts "........."
  puts "\n"
  puts "You can find free WiFi at the following locations: \n"
  zip_array = []

  Scraper.all_data.each do |each_entry|
    if each_entry["zip"] == Cli.find_wifi_input
      zip_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
      zip_array << zip_list unless zip_array.include?(zip_list)
    end #if
  end #do
    puts zip_array.sort
    Cli.search_again_met
end