lib/eia/data.rb in eia-1.0.1 vs lib/eia/data.rb in eia-1.1.1
- old
+ new
@@ -1,7 +1,8 @@
class DataIBGE
- def initialize(date, variable, location, product, unit, value, periodicity)
+ def initialize(table_code, date, variable, location, product, unit, value, periodicity)
+ @table_code = table_code
@date = standardize_date(date, periodicity)
@variable = variable
@location = location
@product = product
@unit = unit
@@ -26,10 +27,14 @@
puts "\nError parsing date for DataIBGE. Attempted to parse #{date}.\n"
return "ERROR"
end
end
+ def table_code
+ return @table_code
+ end
+
def date
return @date
end
def variable
@@ -51,9 +56,14 @@
def value
return @value.to_f
end
def is_valid?
+ if @table_code == '' or @table_code == nil or @table_code.to_i <= 0 then
+ puts "Invalid table code supplied. Value is #{@table_code}."
+ return false
+ end
+
if @date == '' or @date == "ERROR" or @date == nil then
puts "Date found is invalid. Value is '#{@date}'."
return false
end