Class: Nhtsa::SafetyRatings::Trims
- Inherits:
-
Object
- Object
- Nhtsa::SafetyRatings::Trims
- Defined in:
- lib/nhtsa/safety_ratings/trims.rb
Instance Method Summary collapse
- #descriptions ⇒ Object
- #ids ⇒ Object
-
#initialize(year, manufacturer, model) ⇒ Trims
constructor
A new instance of Trims.
- #manufacturer ⇒ Object
- #model ⇒ Object
- #trims ⇒ Object
- #url ⇒ Object
- #year ⇒ Object
Constructor Details
#initialize(year, manufacturer, model) ⇒ Trims
Returns a new instance of Trims.
4 5 6 7 8 9 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 4 def initialize(year, manufacturer, model) @year = Year.new(year) @manufacturer = Manufacturer.new(year, manufacturer) @model = Model.new(year, manufacturer, model) @trims = JSON.parse(open(url).read)["Results"].collect{|trim| Trim.new(trim)} end |
Instance Method Details
#descriptions ⇒ Object
31 32 33 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 31 def descriptions @trims.map(&:trim_description) end |
#ids ⇒ Object
35 36 37 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 35 def ids @trims.map(&:trim_id) end |
#manufacturer ⇒ Object
19 20 21 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 19 def manufacturer @manufacturer end |
#model ⇒ Object
23 24 25 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 23 def model @model end |
#trims ⇒ Object
27 28 29 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 27 def trims @trims end |
#url ⇒ Object
11 12 13 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 11 def url BASE_URI + END_POINT + "/#{@year}/#{URI.encode(@manufacturer.name)}/#{URI.encode(@model.name)}" + DEFAULT_PARAMS end |
#year ⇒ Object
15 16 17 |
# File 'lib/nhtsa/safety_ratings/trims.rb', line 15 def year @year end |