Class: AreaDataValue
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AreaDataValue
- Defined in:
- app/models/area_data_value.rb
Class Method Summary collapse
- .all_data ⇒ Object
-
.by_area_data_variables_and_sample_geog_level(vars, level) ⇒ Object
returns a relation for all the area_data_variables for this sample_geog_level.
Instance Method Summary collapse
Class Method Details
.all_data ⇒ Object
16 17 18 |
# File 'app/models/area_data_value.rb', line 16 def self.all_data includes(:area_data_variable, :geog_instance).order("area_data_values.id") end |
.by_area_data_variables_and_sample_geog_level(vars, level) ⇒ Object
returns a relation for all the area_data_variables for this sample_geog_level. Call .all on the result to actually get the data.
10 11 12 13 |
# File 'app/models/area_data_value.rb', line 10 def self.by_area_data_variables_and_sample_geog_level(vars, level) selected_sample_area_data_variable_ids = vars.map{ |v| v.var_for_sample_level(level) }.flatten.compact.map{|var| var.id} all_data.where(sample_level_area_data_variable_id: selected_sample_area_data_variable_ids) end |
Instance Method Details
#construct_synthetic_mnemonic ⇒ Object
31 32 33 34 |
# File 'app/models/area_data_value.rb', line 31 def construct_synthetic_mnemonic # use the existing code on AreaDataVariable to generate the mnemonic area_data_variable.construct_synthetic_mnemonic(sample_level_area_data_variable.sample_geog_level) end |
#mnemonic_sym ⇒ Object
26 27 28 |
# File 'app/models/area_data_value.rb', line 26 def mnemonic_sym area_data_variable.mnemonic.to_sym end |
#to_s ⇒ Object
21 22 23 |
# File 'app/models/area_data_value.rb', line 21 def to_s value.nil? ? "<not set>" : "#{area_data_variable.mnemonic}: #{value}" end |