lib/eia/data.rb in eia-1.1.4 vs lib/eia/data.rb in eia-1.2.5

- old
+ new

@@ -1,12 +1,15 @@ class DataIBGE - def initialize(table_code, date, variable, location, product, unit, value, periodicity) + def initialize(table_code, date, variable, location, classification, unit, value, periodicity) @table_code = table_code @date = standardize_date(date, periodicity) @variable = variable @location = location - @product = product + + #is an array + @classification = classification + @unit = unit @value = value #The standard is: # 4 : "Trimestral Móvel" @@ -16,15 +19,15 @@ def standardize_date(date, periodicity) #date is a four digit number if periodicity == 5 then return "01/01/#{date}" - elsif periodicity == 4 then + elsif periodicity == 4 or periodicity == 3 then y = date[0..3] m = date[4..5] - return "01/#{m}/#{y}" + return "01/#{m}/#{y}" else puts "\nError parsing date for DataIBGE. Attempted to parse #{date}.\n" return "ERROR" end end @@ -43,12 +46,12 @@ def location return @location end - def product - return @product + def classification + return @classification end def unit return @unit end @@ -92,9 +95,14 @@ return false end if @value == '' or @value == nil then puts "Value found is invalid. Value is '#{@value}'." + return false + end + + if @classification == nil or not @classification.class.to_s.eql? "Array" then + puts "Classification is invalid. Value is nil." return false end return true end