Class: RasterGroup
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RasterGroup
- Includes:
- ApiUtility
- Defined in:
- app/models/raster_group.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_raster_dataset_id_ ⇒ Object
- #begin_year ⇒ Object
- #child_count ⇒ Object
- #description ⇒ Object
- #end_year ⇒ Object
- #in_cart_count(mnemonics) ⇒ Object
- #parent_mnemonic ⇒ Object
- #raster_data_type_id ⇒ Object
- #raster_datasets_count ⇒ Object
- #sorted_children ⇒ Object
- #sorted_variables ⇒ Object
- #table_type ⇒ Object
Class Method Details
.sort_collection(rg_id, collection) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/raster_group.rb', line 20 def self.sort_collection(rg_id, collection) raster_group = RasterGroup.where(id: rg_id).first return collection if raster_group.nil? || !raster_group.respond_to?('sort_operation') case raster_group.sort_operation when 'mnemonic' collection.order(:mnemonic) when 'label' collection.order(:label) when 'mnemonic_month' sort_by_mnemonic_month(collection) else collection end end |
Instance Method Details
#_raster_dataset_id_ ⇒ Object
67 68 69 |
# File 'app/models/raster_group.rb', line 67 def _raster_dataset_id_ nil end |
#begin_year ⇒ Object
75 76 77 |
# File 'app/models/raster_group.rb', line 75 def begin_year nil end |
#child_count ⇒ Object
55 56 57 |
# File 'app/models/raster_group.rb', line 55 def child_count raster_variables.count end |
#description ⇒ Object
71 72 73 |
# File 'app/models/raster_group.rb', line 71 def description name end |
#end_year ⇒ Object
79 80 81 |
# File 'app/models/raster_group.rb', line 79 def end_year nil end |
#in_cart_count(mnemonics) ⇒ Object
59 60 61 |
# File 'app/models/raster_group.rb', line 59 def in_cart_count(mnemonics) raster_variables.where(mnemonic: mnemonics).count end |
#parent_mnemonic ⇒ Object
11 12 13 |
# File 'app/models/raster_group.rb', line 11 def parent_mnemonic parent.mnemonic end |
#raster_data_type_id ⇒ Object
83 84 85 |
# File 'app/models/raster_group.rb', line 83 def raster_data_type_id nil end |
#raster_datasets_count ⇒ Object
63 64 65 |
# File 'app/models/raster_group.rb', line 63 def raster_datasets_count nil end |
#sorted_children ⇒ Object
15 16 17 |
# File 'app/models/raster_group.rb', line 15 def sorted_children sort_operation == 'name' ? children.order(:name) : children end |
#sorted_variables ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/raster_group.rb', line 36 def sorted_variables case sort_operation when 'mnemonic' raster_variables.order(:mnemonic) when 'label' raster_variables.order(:label) when 'mnemonic_month' sort_by_mnemonic_month(raster_variables) when 'alphabetical_weight' raster_variables.sort_by{ |e| [e.sort_weight, e.label] } else raster_variables end end |
#table_type ⇒ Object
51 52 53 |
# File 'app/models/raster_group.rb', line 51 def table_type self.class.to_s end |