eia 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1eff9eb923274d2c74f7118cbcbfedf811797d8
4
- data.tar.gz: 0ed4c7783fa7deafe3ff6ee7c7641b852c3b1cf3
3
+ metadata.gz: fee65d85a6c1c6b22fc59b8680d9c30ceb8854f8
4
+ data.tar.gz: 840613cddc7e0cbae6e0f96e66824e877bd37dee
5
5
  SHA512:
6
- metadata.gz: 61cf88c0aec526f5b1942b12cf0a52397710c4e22fef84c3a7de0c9fadd7190cb2910b175bf7b54c3c40dd188cf175135c5b8f193885bbecb2c164e600bff124
7
- data.tar.gz: 9116b28d1511939004ada9ede003a32a2b752266a808289a9d65db86d5b9bef0983e457a0a79f9b79d21e062d483cdb19373ff2107f030c5e2d0a9b03c56d500
6
+ metadata.gz: c738248a794f00a71396884f11f2ea63e5afd9853b1b87e37f80758c825856231fde995d7f34f2c8e6920f527576298fe651685825f6ac3ea36e6329e544009e
7
+ data.tar.gz: b0c9eb06339443361a9eaae986b7849cb0b80000dd513890e28b2e2a925c98c6ea36a9f41206bb6ff184fe26b81c4e1d8cd9ae1836a66c624853a66001511c72
data/lib/eia/data.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  class DataIBGE
2
- def initialize(date, variable, location, product, unit, value, periodicity)
2
+ def initialize(table_code, date, variable, location, product, unit, value, periodicity)
3
+ @table_code = table_code
3
4
  @date = standardize_date(date, periodicity)
4
5
  @variable = variable
5
6
  @location = location
@@ -28,6 +29,10 @@ class DataIBGE
28
29
  end
29
30
  end
30
31
 
32
+ def table_code
33
+ return @table_code
34
+ end
35
+
31
36
  def date
32
37
  return @date
33
38
  end
@@ -53,6 +58,11 @@ class DataIBGE
53
58
  end
54
59
 
55
60
  def is_valid?
61
+ if @table_code == '' or @table_code == nil or @table_code.to_i <= 0 then
62
+ puts "Invalid table code supplied. Value is #{@table_code}."
63
+ return false
64
+ end
65
+
56
66
  if @date == '' or @date == "ERROR" or @date == nil then
57
67
  puts "Date found is invalid. Value is '#{@date}'."
58
68
  return false
data/lib/eia/ibge.rb CHANGED
@@ -58,10 +58,10 @@ class IBGE
58
58
  url += "/c#{ws[0]}/#{ws[1]}"
59
59
  end
60
60
 
61
- return consume_json(Net::HTTP.get(URI(url)))
61
+ return consume_json(Net::HTTP.get(URI(url)), code)
62
62
  end
63
63
 
64
- def consume_json(json_string)
64
+ def consume_json(json_string, table_code)
65
65
  begin
66
66
  output = JSON.parse(json_string)
67
67
  heading = output.delete_at(0)
@@ -106,7 +106,7 @@ class IBGE
106
106
  end
107
107
  end
108
108
 
109
- data_array << DataIBGE.new(date, variable, location, product, unit, val, periodicity)
109
+ data_array << DataIBGE.new(table_code, date, variable, location, product, unit, val, periodicity)
110
110
  end
111
111
 
112
112
  return data_array
data/lib/eia/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eia
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.1"
3
3
 
4
4
  #Standard for version: xx.yy.zz
5
5
  # xx - release
@@ -26,4 +26,7 @@ module Eia
26
26
  # Version 1.0.1
27
27
  # Fixes periodicty, as to be able to relate possible periodicities from 0 to 5
28
28
 
29
+ # Version 1.1.1
30
+ # adds table_code to data type
31
+
29
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rCamposCruz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-13 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement