class Nhtsa::SafetyRatings::Models

Public Class Methods

new(year, manufacturer) click to toggle source
# File lib/nhtsa/safety_ratings/models.rb, line 4
def initialize(year, manufacturer)
  @year = Year.new(year)
  @manufacturer = Manufacturer.new(year, manufacturer)
  @models = JSON.parse(open(url).read)["Results"].collect{|model| Model.new(@year, @manufacturer, model["Model"])}
end

Public Instance Methods

model_names() click to toggle source
# File lib/nhtsa/safety_ratings/models.rb, line 18
def model_names
  @models.map(&:model_name)
end
models() click to toggle source
# File lib/nhtsa/safety_ratings/models.rb, line 14
def models
  @models
end
to_s() click to toggle source
# File lib/nhtsa/safety_ratings/models.rb, line 22
def to_s
  @models.inject(""){|model_string, model| model_string << "#{model}\n"}
end
url() click to toggle source
# File lib/nhtsa/safety_ratings/models.rb, line 10
def url
  "#{BASE_URI}#{END_POINT}/#{@year}/#{URI.encode(@manufacturer.name)}#{DEFAULT_PARAMS}"
end