Sha256: 238d5fb12d65da0fdd17f54914718342c881a5b2b593c73c76820ef9c8c4a3e3

Contents?: true

Size: 956 Bytes

Versions: 9

Compression:

Stored size: 956 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&hl=en&gid=0&output=csv',
           :errata => { 'url' => 'http://static.brighterplanet.com/science/data/transport/automobiles/make_fleet_years/errata.csv' },
           :select => lambda { |row| row['volume'].to_i > 0 } do
      key   'name', :synthesize => lambda { |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

9 entries across 9 versions & 1 rubygems

Version Path
earth-0.11.16 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.15 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.14 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.13 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.12 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.11 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.10 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.9 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
earth-0.11.8 lib/earth/automobile/automobile_make_year_fleet/data_miner.rb