Class: Nhtsa::SafetyRatings::Manufacturers
- Inherits:
-
Object
- Object
- Nhtsa::SafetyRatings::Manufacturers
- Defined in:
- lib/nhtsa/safety_ratings/manufacturers.rb
Instance Method Summary collapse
-
#initialize(year) ⇒ Manufacturers
constructor
A new instance of Manufacturers.
- #manufacturers ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
- #values ⇒ Object
- #year ⇒ Object
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
#manufacturers ⇒ Object
13 14 15 |
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 13 def manufacturers @manufacturers end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 25 def to_s @manufacturers.map(&:to_s) end |
#url ⇒ Object
9 10 11 |
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 9 def url BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS end |
#values ⇒ Object
21 22 23 |
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 21 def values @manufacturers.map(&:name) end |
#year ⇒ Object
17 18 19 |
# File 'lib/nhtsa/safety_ratings/manufacturers.rb', line 17 def year @year end |