Sha256: bcd044090ed8d92a7eb6d6dfdc04e5adb022f3016ff9c7a3eec1e5c07c32ab77

Contents?: true

Size: 1.89 KB

Versions: 19

Compression:

Stored size: 1.89 KB

Contents

class FuelYear < ActiveRecord::Base
  set_primary_key :name
  
  col :name
  col :fuel_name
  col :year, :type => :integer
  col :energy_content, :type => :float
  col :energy_content_units
  col :carbon_content, :type => :float
  col :carbon_content_units
  col :oxidation_factor, :type => :float
  col :biogenic_fraction, :type => :float
  col :co2_emission_factor, :type => :float
  col :co2_emission_factor_units
  col :co2_biogenic_emission_factor, :type => :float
  col :co2_biogenic_emission_factor_units
  
  # FIXME TODO verify fuel name is in Fuel
  # verify "Fuel name should never be missing" do
  #   FuelYear.all.each do |record|
  #     fuel_name = record.send(:fuel_name)
  #     if fuel_name.nil?
  #       raise "Missing fuel name for FuelYear '#{record.name}'"
  #     end
  #   end
  # end
  # 
  # verify "Year should be from 1990 to 2008" do
  #   FuelYear.all.each do |record|
  #     year = record.send(:year)
  #     unless year > 1989 and year < 2009
  #       raise "Invalid year for FuelYear '#{record.name}': #{year} (should be from 1990 to 2008)"
  #     end
  #   end
  # end
  # 
  # verify "Carbon content and energy content should be greater than zero" do
  #   FuelYear.all.each do |record|
  #     %w{ carbon_content energy_content }.each do |attribute|
  #       value = record.send(:"#{attribute}")
  #       unless value > 0
  #         raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be > 0)"
  #       end
  #     end
  #   end
  # end
  # 
  # verify "Emission factors should be zero or more" do
  #   FuelYear.all.each do |record|
  #     %w{ co2_emission_factor co2_biogenic_emission_factor }.each do |attribute|
  #       value = record.send(:"#{attribute}")
  #       unless value >= 0
  #         raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be >= 0)"
  #       end
  #     end
  #   end
  # end
  # 
  # FIXME TODO verify units
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
earth-0.11.10 lib/earth/fuel/fuel_year.rb
earth-0.11.9 lib/earth/fuel/fuel_year.rb
earth-0.11.8 lib/earth/fuel/fuel_year.rb
earth-0.11.7 lib/earth/fuel/fuel_year.rb
earth-0.11.6 lib/earth/fuel/fuel_year.rb
earth-0.11.5 lib/earth/fuel/fuel_year.rb
earth-0.11.4 lib/earth/fuel/fuel_year.rb
earth-0.11.3 lib/earth/fuel/fuel_year.rb
earth-0.11.2 lib/earth/fuel/fuel_year.rb
earth-0.11.1 lib/earth/fuel/fuel_year.rb
earth-0.11.0 lib/earth/fuel/fuel_year.rb
earth-0.7.0 lib/earth/fuel/fuel_year.rb
earth-0.6.6 lib/earth/fuel/fuel_year.rb
earth-0.6.5 lib/earth/fuel/fuel_year.rb
earth-0.6.4 lib/earth/fuel/fuel_year.rb
earth-0.6.3 lib/earth/fuel/fuel_year.rb
earth-0.6.2 lib/earth/fuel/fuel_year.rb
earth-0.6.1 lib/earth/fuel/fuel_year.rb
earth-0.6.0 lib/earth/fuel/fuel_year.rb