Sha256: fa7502187d01d798c618a79f6ea33ba1bf85a72b15baf8e1e81589f3f278c8b2

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

AutomobileSizeClass.class_eval do
  data_miner do
    # FIXME TODO pull this from AutomobileSizeClassYear
    import "a list of size classes and pre-calculated fuel efficiencies",
           :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHlRUE5IcWlrRENhN0EtUldPTy1rX1E&gid=0&output=csv' do
      key 'name'
      store 'type_name'
      store 'fuel_efficiency_city', :units_field_name => 'fuel_efficiency_city_units'
      store 'fuel_efficiency_highway', :units_field_name => 'fuel_efficiency_highway_units'
    end
    
    process "Ensure AutomobileTypeFuelYearAge is populated" do
      AutomobileTypeFuelYearAge.run_data_miner!
    end
    
    # FIXME TODO make this a method on AutomobileSizeClass?
    process "Calculate annual distance from AutomobileTypeFuelYearAge" do
      ages = AutomobileTypeFuelYearAge.arel_table
      classes = AutomobileSizeClass.arel_table
      conditional_relation = ages[:type_name].eq(classes[:type_name])
      update_all "annual_distance = (#{AutomobileTypeFuelYearAge.weighted_average_relation(:annual_distance, :weighted_by => :vehicles).where(conditional_relation).to_sql})"
      update_all "annual_distance_units = 'kilometres'"
    end
    
    import "pre-calculated fuel efficiency multipliers",
           :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGt2NnhXLXUxNFRJSzczU3BkSHB3enc&hl=en&gid=0&output=csv' do
      key 'name'
      store 'hybrid_fuel_efficiency_city_multiplier'
      store 'hybrid_fuel_efficiency_highway_multiplier'
      store 'conventional_fuel_efficiency_city_multiplier'
      store 'conventional_fuel_efficiency_highway_multiplier'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
earth-0.7.0 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.6 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.5 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.4 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.3 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.2 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.1 lib/earth/automobile/automobile_size_class/data_miner.rb
earth-0.6.0 lib/earth/automobile/automobile_size_class/data_miner.rb