Sha256: 8f9d6ebed9d79a6d17a455e021e04bb4ad3ffacd6c2f6e758dda99134a89ece3

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

FlightSeatClass.class_eval do
  data_miner do
    schema Earth.database_options do
      string   'name'
      string   'distance_class_name'
      string   'seat_class_name'
      float    'multiplier'
    end
    
    import "a list of Brighter Planet-defined seat classes and pre-calculated multipliers",
           :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG5zSER1QmFVVkhNcTM2cmhCMEJtWVE&hl=en&single=true&gid=0&output=csv' do
      key   'name'
      store 'distance_class_name'
      store 'seat_class_name'
      store 'multiplier'
    end
    
    # FIXME TODO verify this
    
    # sabshere 5/21/10 in case we ever need this
    # class << self
    #   def refresh
    #     update_all_weighted_averages(:seats,      :weighted_by => :airline_aircraft_seat_classes)
    #     update_all_weighted_averages(:multiplier, :weighted_by => :airline_aircraft_seat_classes)
    #   end
    # 
    #   def safe_find_by_name(name)
    #     guess = case name.to_s.downcase.gsub(/[^a-z]/, '')
    #     when /first/
    #       'first'
    #     when /busi/, /exec/
    #       'business'
    #     when /econ/, /coach/
    #       'economy'
    #     end
    #     find_or_create_by_name(guess) unless guess.nil?
    #   end
    # end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
earth-0.4.4 lib/earth/air/flight_seat_class/data_miner.rb
earth-0.4.3 lib/earth/air/flight_seat_class/data_miner.rb
earth-0.4.2 lib/earth/air/flight_seat_class/data_miner.rb
earth-0.4.1 lib/earth/air/flight_seat_class/data_miner.rb
earth-0.4.0 lib/earth/air/flight_seat_class/data_miner.rb
earth-0.3.15 lib/earth/air/flight_seat_class/data_miner.rb