Class: Nhtsa::SafetyRatings::Years

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

Instance Method Summary collapse

Constructor Details

#initializeYears

Returns a new instance of Years.



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

def initialize
  @years = JSON.parse(open(url).read)["Results"].collect{|year| Year.new(year["ModelYear"])}
end

Instance Method Details

#to_sObject



20
21
22
# File 'lib/nhtsa/safety_ratings/years.rb', line 20

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

#urlObject



8
9
10
# File 'lib/nhtsa/safety_ratings/years.rb', line 8

def url
  BASE_URI + END_POINT + DEFAULT_PARAMS
end

#valuesObject



16
17
18
# File 'lib/nhtsa/safety_ratings/years.rb', line 16

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

#yearsObject



12
13
14
# File 'lib/nhtsa/safety_ratings/years.rb', line 12

def years
  @years
end