lib/earth/eia.rb in earth-0.11.7 vs lib/earth/eia.rb in earth-0.11.8
- old
+ new
@@ -1,24 +1,22 @@
+require 'earth'
module Earth
module EIA
extend self
def normalize(model, fields)
model.all.each do |record|
- fields.each do |field|
- value = record.send field
- normalized_value = if value == 'Q'
- 0
- elsif value == 'W'
- 0
- elsif value == '*'
- 0
- else
- value
- end
- record.send "#{field}=", normalized_value
+ fields.each do |k|
+ v = record.send k
+ normalized_v = case v
+ when 'Q', 'W', '*'
+ 0
+ else
+ v
+ end
+ record.send "#{k}=", normalized_v
end
- record.save
+ record.save!
end
end
end
end