Class: Nhtsa::SafetyRatings::Models

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

Instance Method Summary collapse

Constructor Details

#initialize(year, manufacturer) ⇒ Models

Returns a new instance of Models.



34
35
36
37
# File 'lib/nhtsa/safety_ratings.rb', line 34

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

Instance Method Details

#modelsObject



43
44
45
# File 'lib/nhtsa/safety_ratings.rb', line 43

def models
  JSON.parse(open(url).read)["Results"].collect{|model| model["Model"]}
end

#urlObject



39
40
41
# File 'lib/nhtsa/safety_ratings.rb', line 39

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