Class: Nhtsa::SafetyRatings::Trims
- Inherits:
-
Object
- Object
- Nhtsa::SafetyRatings::Trims
- Defined in:
- lib/nhtsa/safety_ratings.rb
Instance Method Summary collapse
-
#initialize(year, manufacturer, model) ⇒ Trims
constructor
A new instance of Trims.
- #trim_descriptions ⇒ Object
- #trim_ids ⇒ Object
- #trims ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(year, manufacturer, model) ⇒ Trims
Returns a new instance of Trims.
49 50 51 52 53 |
# File 'lib/nhtsa/safety_ratings.rb', line 49 def initialize(year, manufacturer, model) @year = year @manufacturer = URI::encode(manufacturer) @model = URI::encode(model) end |
Instance Method Details
#trim_descriptions ⇒ Object
68 69 70 |
# File 'lib/nhtsa/safety_ratings.rb', line 68 def trim_descriptions JSON.parse(open(url).read)["Results"].collect{|trim| trim["VehicleDescription"]} end |
#trim_ids ⇒ Object
72 73 74 |
# File 'lib/nhtsa/safety_ratings.rb', line 72 def trim_ids JSON.parse(open(url).read)["Results"].collect{|trim| trim["VehicleId"]} end |
#trims ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/nhtsa/safety_ratings.rb', line 59 def trims JSON.parse(open(url).read)["Results"].collect do |trim| { :description => trim["VehicleDescription"], :id => trim["VehicleId"] } end end |
#url ⇒ Object
55 56 57 |
# File 'lib/nhtsa/safety_ratings.rb', line 55 def url BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS end |