Class: RasterGroup

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ApiUtility
Defined in:
app/models/raster_group.rb

Class Method Summary collapse

Instance Method Summary collapse

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_yearObject



75
76
77
# File 'app/models/raster_group.rb', line 75

def begin_year
  nil
end

#child_countObject



55
56
57
# File 'app/models/raster_group.rb', line 55

def child_count
  raster_variables.count
end

#descriptionObject



71
72
73
# File 'app/models/raster_group.rb', line 71

def description
  name
end

#end_yearObject



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_mnemonicObject



11
12
13
# File 'app/models/raster_group.rb', line 11

def parent_mnemonic
  parent.mnemonic
end

#raster_data_type_idObject



83
84
85
# File 'app/models/raster_group.rb', line 83

def raster_data_type_id
  nil
end

#raster_datasets_countObject



63
64
65
# File 'app/models/raster_group.rb', line 63

def raster_datasets_count
  nil
end

#sorted_childrenObject



15
16
17
# File 'app/models/raster_group.rb', line 15

def sorted_children
  sort_operation == 'name' ? children.order(:name) : children
end

#sorted_variablesObject



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_typeObject



51
52
53
# File 'app/models/raster_group.rb', line 51

def table_type
  self.class.to_s
end