Class: Nhtsa::SafetyRatings::Manufacturers

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

Instance Method Summary collapse

Constructor Details

#initialize(year) ⇒ Manufacturers



4
5
6
7
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 4

def initialize(year)
  @year = Year.new(year)
  @manufacturers = JSON.parse(open(url).read)["Results"].collect{|manufacturer| Manufacturer.new(@year, manufacturer["Make"])}
end

Instance Method Details

#manufacturersObject



13
14
15
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 13

def manufacturers
  @manufacturers
end

#to_sObject



25
26
27
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 25

def to_s
  @manufacturers.map(&:to_s)
end

#urlObject



9
10
11
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 9

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

#valuesObject



21
22
23
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 21

def values
  @manufacturers.map(&:name)
end

#yearObject



17
18
19
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 17

def year
  @year
end