Class: SfAircraftNoiseComplaints::Complaint

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Complaint

Returns a new instance of Complaint.



9
10
11
12
13
14
# File 'lib/sf_aircraft_noise_complaints.rb', line 9

def initialize(hash)
  @community = hash["community"]
  @year = hash["year"]
  @no_of_complaints = hash["total_complaints"]
  @no_of_callers = hash["total_number_of_callers"]
end

Instance Attribute Details

#communityObject (readonly)

Returns the value of attribute community.



7
8
9
# File 'lib/sf_aircraft_noise_complaints.rb', line 7

def community
  @community
end

#no_of_callersObject (readonly)

Returns the value of attribute no_of_callers.



7
8
9
# File 'lib/sf_aircraft_noise_complaints.rb', line 7

def no_of_callers
  @no_of_callers
end

#no_of_complaintsObject (readonly)

Returns the value of attribute no_of_complaints.



7
8
9
# File 'lib/sf_aircraft_noise_complaints.rb', line 7

def no_of_complaints
  @no_of_complaints
end

#yearObject (readonly)

Returns the value of attribute year.



7
8
9
# File 'lib/sf_aircraft_noise_complaints.rb', line 7

def year
  @year
end

Class Method Details

.allObject



16
17
18
19
20
21
22
23
# File 'lib/sf_aircraft_noise_complaints.rb', line 16

def self.all
  complaints_array = Unirest.get("https://data.sfgov.org/resource/bw78-hmt5.json").body
  complaints = []
  complaints_array.each do |complaint_hash|
    complaints.push(Complaint.new(complaint_hash))
  end
  return complaints
end