Class: Nhtsa::Complaints::Complaints

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

Instance Method Summary collapse

Constructor Details

#initialize(year, manufacturer, model) ⇒ Complaints



4
5
6
7
8
# File 'lib/nhtsa/complaints/complaints.rb', line 4

def initialize(year, manufacturer, model)
  @year = year
  @manufacturer = URI::encode(manufacturer)
  @model = URI::encode(model)
end

Instance Method Details

#complaintsObject



14
15
16
# File 'lib/nhtsa/complaints/complaints.rb', line 14

def complaints
  JSON.parse(open(url).read)["Results"]
end

#urlObject



10
11
12
# File 'lib/nhtsa/complaints/complaints.rb', line 10

def url
  BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS
end