Class: DataRequestVariable
- Inherits:
-
Object
- Object
- DataRequestVariable
- Defined in:
- lib/data_request.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#frequencies ⇒ Object
readonly
Returns the value of attribute frequencies.
-
#realms ⇒ Object
readonly
Returns the value of attribute realms.
-
#standard_name ⇒ Object
readonly
Returns the value of attribute standard_name.
-
#time_method ⇒ Object
readonly
Returns the value of attribute time_method.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#variable_id ⇒ Object
readonly
Returns the value of attribute variable_id.
Class Method Summary collapse
Instance Method Summary collapse
- #cell_measures_in_table(table_id) ⇒ Object
- #cell_methods_in_table(table_id) ⇒ Object
- #frequency_in_table(table_id) ⇒ Object
-
#initialize(variable_id, unit, description, time_method, table, frequency, realms, standard_name, cell_methods, cell_measures) ⇒ DataRequestVariable
constructor
A new instance of DataRequestVariable.
- #merge_table_var_entry(var_entry) ⇒ Object
- #table_ids ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(variable_id, unit, description, time_method, table, frequency, realms, standard_name, cell_methods, cell_measures) ⇒ DataRequestVariable
Returns a new instance of DataRequestVariable.
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/data_request.rb', line 134 def initialize(variable_id, unit, description, time_method, table, frequency, realms, standard_name, cell_methods, cell_measures) @variable_id = variable_id @unit = unit @description = description @time_method = time_method @tables = [table] @frequencies = [frequency] @realms = realms @standard_name = standard_name @cell_methods_list = [cell_methods] @cell_measures_list = [cell_measures] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
127 128 129 |
# File 'lib/data_request.rb', line 127 def description @description end |
#frequencies ⇒ Object (readonly)
Returns the value of attribute frequencies.
127 128 129 |
# File 'lib/data_request.rb', line 127 def frequencies @frequencies end |
#realms ⇒ Object (readonly)
Returns the value of attribute realms.
127 128 129 |
# File 'lib/data_request.rb', line 127 def realms @realms end |
#standard_name ⇒ Object (readonly)
Returns the value of attribute standard_name.
127 128 129 |
# File 'lib/data_request.rb', line 127 def standard_name @standard_name end |
#time_method ⇒ Object (readonly)
Returns the value of attribute time_method.
127 128 129 |
# File 'lib/data_request.rb', line 127 def time_method @time_method end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
127 128 129 |
# File 'lib/data_request.rb', line 127 def unit @unit end |
#variable_id ⇒ Object (readonly)
Returns the value of attribute variable_id.
127 128 129 |
# File 'lib/data_request.rb', line 127 def variable_id @variable_id end |
Class Method Details
.new_from_table_var_entry(var_entry) ⇒ Object
129 130 131 |
# File 'lib/data_request.rb', line 129 def self.new_from_table_var_entry(var_entry) DataRequestVariable.new(var_entry.variable_id, var_entry.unit, var_entry.description, var_entry.time_method, var_entry.table, var_entry.frequency_name, var_entry.realms, var_entry.standard_name, var_entry.cell_methods, var_entry.cell_measures) end |
Instance Method Details
#cell_measures_in_table(table_id) ⇒ Object
176 177 178 179 180 |
# File 'lib/data_request.rb', line 176 def cell_measures_in_table(table_id) i = table_ids.index(table_id) raise "variable_id '#{variable_id}' is not associated with table_id '#{table_id}', available table_id(s): #{table_ids.join(', ')}" unless i @cell_measures_list[i] end |
#cell_methods_in_table(table_id) ⇒ Object
169 170 171 172 173 |
# File 'lib/data_request.rb', line 169 def cell_methods_in_table(table_id) i = table_ids.index(table_id) raise "variable_id '#{variable_id}' is not associated with table_id '#{table_id}', available table_id(s): #{table_ids.join(', ')}" unless i @cell_methods_list[i] end |
#frequency_in_table(table_id) ⇒ Object
162 163 164 165 166 |
# File 'lib/data_request.rb', line 162 def frequency_in_table(table_id) i = table_ids.index(table_id) raise "variable_id '#{variable_id}' is not associated with table_id '#{table_id}', available table_id(s): #{table_ids.join(', ')}" unless i @frequencies[i] end |
#merge_table_var_entry(var_entry) ⇒ Object
148 149 150 151 152 153 154 |
# File 'lib/data_request.rb', line 148 def merge_table_var_entry(var_entry) @tables << var_entry.table @frequencies << var_entry.frequency_name @cell_methods_list << var_entry.cell_methods # some variables have different entries for cell_methods for different tables @cell_measures_list << var_entry.cell_measures # some variables have different entries for cell_measures for different tables # we do not merge time methods, as we treat identical variable_ids with different time methods as different variables end |
#table_ids ⇒ Object
157 158 159 |
# File 'lib/data_request.rb', line 157 def table_ids @tables.map {|t| t.table_id} end |
#to_s ⇒ Object
183 184 185 |
# File 'lib/data_request.rb', line 183 def to_s "#{variable_id} '#{unit}' [#{frequencies.join(' ')}] [#{@tables.map{|t| t.table_id}.join(' ')}]" end |