Sha256: 571c4f1d6ca3ffa66fdf53aeae7e0b6132376d9cf7998d3cbc269a03cbc1c31d

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

require 'earth/fuel/data_miner'
AutomobileMakeYearFleet.class_eval do
  data_miner do
    import "annual corporate average fuel economy data for domestic and imported vehicle fleets from the NHTSA",
           :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEdXWXB6dkVLWkowLXhYSFVUT01sS2c&output=csv',
           :errata => { :url => "file://#{Earth::ERRATA_DIR}/automobile_make_year_fleet/cafe_errata.csv", :encoding => 'ISO-8859-1' },
           :select => proc { |row| row['volume'].to_i > 0 } do
      key   'name', :synthesize => proc { |row| [ row['manufacturer_name'], row['year_content'], row['fleet'][2,2] ].join ' ' }
      store 'make_name', :field_name => 'manufacturer_name'
      store 'year', :field_name => 'year_content'
      store 'fleet', :chars => 2..3 # zero-based
      store 'fuel_efficiency', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
      store 'volume'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
earth-0.11.20 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.19 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.18 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.17 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb