earth 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/TODO +2 -0
- data/bin/earth_tester.rb +62 -9
- data/earth.gemspec +7 -4
- data/lib/earth.rb +18 -17
- data/lib/earth/air.rb +2 -0
- data/lib/earth/air/aircraft.rb +76 -19
- data/lib/earth/air/aircraft/data_miner.rb +1 -63
- data/lib/earth/air/aircraft_class.rb +48 -12
- data/lib/earth/air/aircraft_class/data_miner.rb +3 -46
- data/lib/earth/air/aircraft_fuel_use_equation.rb +11 -13
- data/lib/earth/air/aircraft_instance.rb +9 -0
- data/lib/earth/air/aircraft_instance_seat_class.rb +12 -0
- data/lib/earth/air/airline.rb +6 -8
- data/lib/earth/air/airline/data_miner.rb +3 -3
- data/lib/earth/air/airport.rb +8 -10
- data/lib/earth/air/airport/data_miner.rb +1 -1
- data/lib/earth/air/bts_aircraft.rb +3 -5
- data/lib/earth/air/flight_distance_class.rb +4 -6
- data/lib/earth/air/flight_seat_class.rb +5 -7
- data/lib/earth/air/flight_segment.rb +58 -42
- data/lib/earth/air/flight_segment/data_miner.rb +11 -26
- data/lib/earth/automobile.rb +1 -0
- data/lib/earth/automobile/automobile_fuel.rb +78 -25
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +5 -72
- data/lib/earth/automobile/automobile_make.rb +14 -6
- data/lib/earth/automobile/automobile_make/data_miner.rb +20 -35
- data/lib/earth/automobile/automobile_make_fleet_year.rb +39 -10
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +0 -29
- data/lib/earth/automobile/automobile_make_model.rb +30 -9
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +11 -26
- data/lib/earth/automobile/automobile_make_model_year.rb +41 -12
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +14 -34
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +56 -38
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +15 -61
- data/lib/earth/automobile/automobile_make_year.rb +15 -8
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +17 -51
- data/lib/earth/automobile/automobile_size_class.rb +78 -14
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +0 -66
- data/lib/earth/automobile/automobile_size_class_year.rb +38 -10
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -30
- data/lib/earth/automobile/automobile_type_fuel_age.rb +60 -11
- data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +10 -65
- data/lib/earth/automobile/automobile_type_fuel_control.rb +41 -10
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +0 -33
- data/lib/earth/automobile/automobile_type_fuel_year.rb +60 -15
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -52
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +64 -12
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +1 -59
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +31 -10
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +2 -32
- data/lib/earth/automobile/automobile_type_year.rb +51 -10
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -43
- data/lib/earth/automobile/data_miner.rb +1 -0
- data/lib/earth/bus/bus_class.rb +108 -28
- data/lib/earth/bus/bus_class/data_miner.rb +0 -88
- data/lib/earth/bus/bus_fuel.rb +83 -15
- data/lib/earth/bus/bus_fuel/data_miner.rb +0 -76
- data/lib/earth/bus/bus_fuel_control.rb +8 -10
- data/lib/earth/bus/bus_fuel_year_control.rb +7 -9
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -5
- data/lib/earth/computation/computation_carrier.rb +11 -5
- data/lib/earth/computation/computation_carrier/data_miner.rb +0 -7
- data/lib/earth/computation/computation_carrier_instance_class.rb +25 -8
- data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +0 -18
- data/lib/earth/computation/computation_carrier_region.rb +5 -7
- data/lib/earth/diet/diet_class.rb +14 -16
- data/lib/earth/diet/food_group.rb +7 -9
- data/lib/earth/fuel/fuel.rb +14 -16
- data/lib/earth/fuel/fuel/data_miner.rb +7 -3
- data/lib/earth/fuel/fuel_price.rb +4 -6
- data/lib/earth/fuel/fuel_type.rb +12 -14
- data/lib/earth/fuel/fuel_year.rb +57 -16
- data/lib/earth/fuel/fuel_year/data_miner.rb +0 -43
- data/lib/earth/fuel/greenhouse_gas.rb +46 -9
- data/lib/earth/fuel/greenhouse_gas/data_miner.rb +0 -38
- data/lib/earth/hospitality/lodging_class.rb +10 -12
- data/lib/earth/industry/industry.rb +3 -5
- data/lib/earth/industry/industry_product.rb +6 -8
- data/lib/earth/industry/industry_product_line.rb +5 -7
- data/lib/earth/industry/industry_sector.rb +5 -7
- data/lib/earth/industry/merchant.rb +4 -6
- data/lib/earth/industry/merchant_category.rb +3 -5
- data/lib/earth/industry/merchant_category_industry.rb +5 -7
- data/lib/earth/industry/product_line.rb +5 -7
- data/lib/earth/industry/product_line_industry_product.rb +5 -7
- data/lib/earth/industry/sector.rb +5 -7
- data/lib/earth/locality/census_division.rb +21 -23
- data/lib/earth/locality/census_region.rb +3 -5
- data/lib/earth/locality/climate_division.rb +5 -7
- data/lib/earth/locality/country.rb +13 -15
- data/lib/earth/locality/egrid_region.rb +14 -5
- data/lib/earth/locality/egrid_region/data_miner.rb +0 -10
- data/lib/earth/locality/egrid_subregion.rb +71 -18
- data/lib/earth/locality/egrid_subregion/data_miner.rb +0 -59
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +6 -8
- data/lib/earth/locality/state.rb +6 -8
- data/lib/earth/locality/urbanity.rb +2 -4
- data/lib/earth/locality/urbanity/data_miner.rb +7 -3
- data/lib/earth/locality/zip_code.rb +8 -10
- data/lib/earth/pet/breed.rb +5 -7
- data/lib/earth/pet/breed_gender.rb +6 -8
- data/lib/earth/pet/gender.rb +2 -4
- data/lib/earth/pet/species.rb +15 -17
- data/lib/earth/rail/rail_class.rb +64 -14
- data/lib/earth/rail/rail_class/data_miner.rb +0 -51
- data/lib/earth/residence/air_conditioner_use.rb +4 -6
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +7 -3
- data/lib/earth/residence/clothes_machine_use.rb +4 -6
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +11 -9
- data/lib/earth/residence/dishwasher_use.rb +4 -6
- data/lib/earth/residence/dishwasher_use/data_miner.rb +11 -9
- data/lib/earth/residence/residence_appliance.rb +4 -6
- data/lib/earth/residence/residence_class.rb +2 -4
- data/lib/earth/residence/residence_class/data_miner.rb +7 -3
- data/lib/earth/residence/residence_fuel_price.rb +12 -14
- data/lib/earth/residence/residence_fuel_price/data_miner.rb +7 -0
- data/lib/earth/residence/residence_fuel_type.rb +6 -8
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +91 -93
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +9 -8
- data/lib/earth/shipping/carrier.rb +57 -10
- data/lib/earth/shipping/carrier/data_miner.rb +0 -48
- data/lib/earth/shipping/carrier_mode.rb +41 -10
- data/lib/earth/shipping/carrier_mode/data_miner.rb +0 -33
- data/lib/earth/shipping/shipment_mode.rb +30 -7
- data/lib/earth/shipping/shipment_mode/data_miner.rb +0 -23
- data/lib/earth/utils.rb +45 -0
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/aircraft_spec.rb +1 -1
- data/vendor/clean_find_in_batches/init.rb +35 -0
- metadata +74 -47
@@ -11,12 +11,10 @@ class FoodGroup < ActiveRecord::Base
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
14
|
+
col :name
|
15
|
+
col :intensity, :type => :float
|
16
|
+
col :intensity_units
|
17
|
+
col :energy, :type => :float
|
18
|
+
col :energy_units
|
19
|
+
col :suggested_imperial_measurement # ?
|
20
|
+
end
|
data/lib/earth/fuel/fuel.rb
CHANGED
@@ -3,21 +3,19 @@ class Fuel < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :fuel_years, :foreign_key => 'fuel_name'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
string 'co2_biogenic_emission_factor_units'
|
20
|
-
end
|
6
|
+
col :name
|
7
|
+
col :density, :type => :float
|
8
|
+
col :density_units
|
9
|
+
col :energy_content, :type => :float
|
10
|
+
col :energy_content_units
|
11
|
+
col :carbon_content, :type => :float
|
12
|
+
col :carbon_content_units
|
13
|
+
col :oxidation_factor, :type => :float
|
14
|
+
col :biogenic_fraction, :type => :float
|
15
|
+
col :co2_emission_factor, :type => :float
|
16
|
+
col :co2_emission_factor_units
|
17
|
+
col :co2_biogenic_emission_factor, :type => :float
|
18
|
+
col :co2_biogenic_emission_factor_units
|
21
19
|
|
22
20
|
def latest_year
|
23
21
|
fuel_years.find_by_year(fuel_years.maximum('year'))
|
@@ -102,4 +100,4 @@ class Fuel < ActiveRecord::Base
|
|
102
100
|
latest_year.co2_biogenic_emission_factor_units
|
103
101
|
end
|
104
102
|
end
|
105
|
-
end
|
103
|
+
end
|
@@ -5,9 +5,13 @@ Fuel.class_eval do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
process "Derive fuel names from FuelYear" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
::Earth::Utils.insert_ignore(
|
9
|
+
:src => FuelYear,
|
10
|
+
:dest => Fuel,
|
11
|
+
:cols => {
|
12
|
+
:fuel_name => :name
|
13
|
+
}
|
14
|
+
)
|
11
15
|
end
|
12
16
|
|
13
17
|
import "fuels with non-variable characteristics",
|
data/lib/earth/fuel/fuel_type.rb
CHANGED
@@ -12,17 +12,15 @@ class FuelType < ActiveRecord::Base
|
|
12
12
|
prices.average :price
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
15
|
+
col :name
|
16
|
+
col :emission_factor, :type => :float
|
17
|
+
col :emission_factor_units
|
18
|
+
col :density, :type => :float
|
19
|
+
col :density_units
|
20
|
+
col :average_purchase_volume, :type => :float
|
21
|
+
col :average_purchase_volume_units
|
22
|
+
# col :energy_content, :type => :float
|
23
|
+
# col :energy_content_units
|
24
|
+
# col :carbon_content, :type => :float
|
25
|
+
# col :carbon_content_units
|
26
|
+
end
|
data/lib/earth/fuel/fuel_year.rb
CHANGED
@@ -1,19 +1,60 @@
|
|
1
1
|
class FuelYear < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
col :name
|
5
|
+
col :fuel_name
|
6
|
+
col :year, :type => :integer
|
7
|
+
col :energy_content, :type => :float
|
8
|
+
col :energy_content_units
|
9
|
+
col :carbon_content, :type => :float
|
10
|
+
col :carbon_content_units
|
11
|
+
col :oxidation_factor, :type => :float
|
12
|
+
col :biogenic_fraction, :type => :float
|
13
|
+
col :co2_emission_factor, :type => :float
|
14
|
+
col :co2_emission_factor_units
|
15
|
+
col :co2_biogenic_emission_factor, :type => :float
|
16
|
+
col :co2_biogenic_emission_factor_units
|
17
|
+
|
18
|
+
# FIXME TODO verify fuel name is in Fuel
|
19
|
+
# verify "Fuel name should never be missing" do
|
20
|
+
# FuelYear.all.each do |record|
|
21
|
+
# fuel_name = record.send(:fuel_name)
|
22
|
+
# if fuel_name.nil?
|
23
|
+
# raise "Missing fuel name for FuelYear '#{record.name}'"
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# verify "Year should be from 1990 to 2008" do
|
29
|
+
# FuelYear.all.each do |record|
|
30
|
+
# year = record.send(:year)
|
31
|
+
# unless year > 1989 and year < 2009
|
32
|
+
# raise "Invalid year for FuelYear '#{record.name}': #{year} (should be from 1990 to 2008)"
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# verify "Carbon content and energy content should be greater than zero" do
|
38
|
+
# FuelYear.all.each do |record|
|
39
|
+
# %w{ carbon_content energy_content }.each do |attribute|
|
40
|
+
# value = record.send(:"#{attribute}")
|
41
|
+
# unless value > 0
|
42
|
+
# raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be > 0)"
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# verify "Emission factors should be zero or more" do
|
49
|
+
# FuelYear.all.each do |record|
|
50
|
+
# %w{ co2_emission_factor co2_biogenic_emission_factor }.each do |attribute|
|
51
|
+
# value = record.send(:"#{attribute}")
|
52
|
+
# unless value >= 0
|
53
|
+
# raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be >= 0)"
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# FIXME TODO verify units
|
60
|
+
end
|
@@ -82,48 +82,5 @@ FuelYear.class_eval do
|
|
82
82
|
WHERE energy_content_units = 'megajoules_per_cubic_metre'
|
83
83
|
}
|
84
84
|
end
|
85
|
-
|
86
|
-
# FIXME TODO verify fuel name is in Fuel
|
87
|
-
verify "Fuel name should never be missing" do
|
88
|
-
FuelYear.all.each do |record|
|
89
|
-
fuel_name = record.send(:fuel_name)
|
90
|
-
if fuel_name.nil?
|
91
|
-
raise "Missing fuel name for FuelYear '#{record.name}'"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
verify "Year should be from 1990 to 2008" do
|
97
|
-
FuelYear.all.each do |record|
|
98
|
-
year = record.send(:year)
|
99
|
-
unless year > 1989 and year < 2009
|
100
|
-
raise "Invalid year for FuelYear '#{record.name}': #{year} (should be from 1990 to 2008)"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
verify "Carbon content and energy content should be greater than zero" do
|
106
|
-
FuelYear.all.each do |record|
|
107
|
-
%w{ carbon_content energy_content }.each do |attribute|
|
108
|
-
value = record.send(:"#{attribute}")
|
109
|
-
unless value > 0
|
110
|
-
raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be > 0)"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
verify "Emission factors should be zero or more" do
|
117
|
-
FuelYear.all.each do |record|
|
118
|
-
%w{ co2_emission_factor co2_biogenic_emission_factor }.each do |attribute|
|
119
|
-
value = record.send(:"#{attribute}")
|
120
|
-
unless value >= 0
|
121
|
-
raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be >= 0)"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
# FIXME TODO verify units
|
128
85
|
end
|
129
86
|
end
|
@@ -7,12 +7,49 @@ class GreenhouseGas < ActiveRecord::Base
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
col :name
|
11
|
+
col :abbreviation
|
12
|
+
col :ipcc_report
|
13
|
+
col :time_horizon, :type => :integer
|
14
|
+
col :time_horizon_units
|
15
|
+
col :global_warming_potential, :type => :integer
|
16
|
+
|
17
|
+
# verify "Abbreviation and IPCC report should never be missing" do
|
18
|
+
# GreenhouseGas.all.each do |record|
|
19
|
+
# %w{ abbreviation ipcc_report }.each do |attribute|
|
20
|
+
# value = record.send(:"#{attribute}")
|
21
|
+
# unless value.present?
|
22
|
+
# raise "Missing #{attribute} for GreenhouseGas '#{record.name}'"
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# verify "Time horizon should be 100" do
|
29
|
+
# GreenhouseGas.all.each do |record|
|
30
|
+
# value = record.send(:time_horizon)
|
31
|
+
# unless value == 100
|
32
|
+
# raise "Invalid time horizon for GreenhouseGas '#{record.name}': #{value} (should be 100)"
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# verify "Time horizon units should be years" do
|
38
|
+
# GreenhouseGas.all.each do |record|
|
39
|
+
# units = record.send(:time_horizon_units)
|
40
|
+
# unless units == "years"
|
41
|
+
# raise "Invalid time horizon units for GreenhouseGas '#{record.name}': #{units} (should be years)"
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# verify "Global warming potential should be one or more" do
|
47
|
+
# GreenhouseGas.all.each do |record|
|
48
|
+
# value = record.send(:global_warming_potential)
|
49
|
+
# unless value >= 1
|
50
|
+
# raise "Invalid global warming potential for GreenhouseGas '#{record.name}': #{value} (should >= 1)"
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
|
55
|
+
end
|
@@ -8,43 +8,5 @@ GreenhouseGas.class_eval do
|
|
8
8
|
store 'time_horizon', :units_field_name => 'time_horizon_units'
|
9
9
|
store 'global_warming_potential'
|
10
10
|
end
|
11
|
-
|
12
|
-
verify "Abbreviation and IPCC report should never be missing" do
|
13
|
-
GreenhouseGas.all.each do |record|
|
14
|
-
%w{ abbreviation ipcc_report }.each do |attribute|
|
15
|
-
value = record.send(:"#{attribute}")
|
16
|
-
unless value.present?
|
17
|
-
raise "Missing #{attribute} for GreenhouseGas '#{record.name}'"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
verify "Time horizon should be 100" do
|
24
|
-
GreenhouseGas.all.each do |record|
|
25
|
-
value = record.send(:time_horizon)
|
26
|
-
unless value == 100
|
27
|
-
raise "Invalid time horizon for GreenhouseGas '#{record.name}': #{value} (should be 100)"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
verify "Time horizon units should be years" do
|
33
|
-
GreenhouseGas.all.each do |record|
|
34
|
-
units = record.send(:time_horizon_units)
|
35
|
-
unless units == "years"
|
36
|
-
raise "Invalid time horizon units for GreenhouseGas '#{record.name}': #{units} (should be years)"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
verify "Global warming potential should be one or more" do
|
42
|
-
GreenhouseGas.all.each do |record|
|
43
|
-
value = record.send(:global_warming_potential)
|
44
|
-
unless value >= 1
|
45
|
-
raise "Invalid global warming potential for GreenhouseGas '#{record.name}': #{value} (should >= 1)"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
11
|
end
|
50
12
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
class LodgingClass < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
4
|
+
col :name
|
5
|
+
col :electricity_intensity, :type => :float
|
6
|
+
col :electricity_intensity_units
|
7
|
+
col :natural_gas_intensity, :type => :float
|
8
|
+
col :natural_gas_intensity_units
|
9
|
+
col :fuel_oil_intensity, :type => :float
|
10
|
+
col :fuel_oil_intensity_units
|
11
|
+
col :district_heat_intensity, :type => :float
|
12
|
+
col :district_heat_intensity_units
|
13
|
+
end
|
@@ -9,13 +9,11 @@ class Industry < ActiveRecord::Base
|
|
9
9
|
has_many :industry_sectors, :foreign_key => 'naics_code'
|
10
10
|
has_many :sectors, :through => :industry_sectors
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
string 'description'
|
15
|
-
end
|
12
|
+
col :naics_code
|
13
|
+
col :description
|
16
14
|
|
17
15
|
def trade_industry?
|
18
16
|
prefix = naics_code.to_s[0,2]
|
19
17
|
%w{42 44 45}.include?(prefix)
|
20
18
|
end
|
21
|
-
end
|
19
|
+
end
|
@@ -5,11 +5,9 @@ class IndustryProduct < ActiveRecord::Base
|
|
5
5
|
|
6
6
|
belongs_to :industry, :foreign_key => 'naics_code'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
8
|
+
col :naics_product_code
|
9
|
+
col :description
|
10
|
+
col :value, :type => :float
|
11
|
+
col :value_units
|
12
|
+
col :naics_code
|
13
|
+
end
|
@@ -4,10 +4,8 @@ class IndustryProductLine < ActiveRecord::Base
|
|
4
4
|
belongs_to :industry, :foreign_key => 'naics_code'
|
5
5
|
belongs_to :product_line, :foreign_key => 'ps_code'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
7
|
+
col :row_hash
|
8
|
+
col :naics_code
|
9
|
+
col :ratio, :type => :float
|
10
|
+
col :ps_code
|
11
|
+
end
|
@@ -4,10 +4,8 @@ class IndustrySector < ActiveRecord::Base
|
|
4
4
|
belongs_to :industry, :foreign_key => 'naics_code'
|
5
5
|
belongs_to :sector, :foreign_key => 'io_code'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
7
|
+
col :row_hash
|
8
|
+
col :naics_code
|
9
|
+
col :ratio, :type => :float
|
10
|
+
col :io_code
|
11
|
+
end
|