Class: FirehouseReader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ FirehouseReader

Returns a new instance of FirehouseReader.



5
6
7
# File 'lib/firehouse_reader.rb', line 5

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/firehouse_reader.rb', line 3

def url
  @url
end

Instance Method Details

#seed_dbObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/firehouse_reader.rb', line 9

def seed_db
  JSON.parse(RestClient.get(url))["data"].each do |line|
    next if line.last == "Borough"
    f = Firehouse.create
    f.address = "#{line[9]} #{line[10]}, NY"
    f.save
    puts "Geocoding: #{f.address}"
    sleep 5
  end
end