brasil-estados 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brasil-estados/estado.rb +14 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f52ecdb1d2f6a4a2807c3f56d84ce8a139c4015c
4
- data.tar.gz: a6597b90465cd3ca63510b494fcc8de675b97033
3
+ metadata.gz: fc106892731e28c4ea7a23dbe768df5e72b30c2a
4
+ data.tar.gz: 4fb269f0b9fa0b0025cab2cb88d277d42e8a2434
5
5
  SHA512:
6
- metadata.gz: ef098d625c9c3c2950d1990a9c592551cfbed0e7cc976738e20946a284c009d51909fda8d41a61b3821ba74b1d516f65169a73a7c4be7b2987ee31e6d0bad649
7
- data.tar.gz: 05b9307afc546b97ede52f7ec869b68aa57658e017d76a3cfee27eba107f95420268958f5166ced3d9dac18d93cc26e65a924e456588ac8a05115f9be3ae5aa1
6
+ metadata.gz: bc3e57d9ede2a588aa142303a99390d1ff08191c0d4e3e551bd0515c36c940a79ef1886fcd7a9bb8829e5c36e4c2db1ec35af66857dac929215817b96e7548a4
7
+ data.tar.gz: 71ce20501b7ac00ec63eb2e12afeb5bd7a6070615feffc7e11c23fd2c21c767463170d3bd4e61510f2d13687f925627eec9ffc85b3672d6750ed6ed33994c1de
@@ -26,7 +26,16 @@ module Brasil
26
26
  end
27
27
  end
28
28
 
29
- estados
29
+ raise ArgumentError, "Not a valid regiao" if estados.empty?
30
+ raise ArgumentError, "Invalid information requested" if !valid_info?(info_requested)
31
+
32
+ return estados unless info_requested
33
+
34
+ if !estados.empty? && valid_info?(info_requested)
35
+ return estados.map do |estado|
36
+ estado.public_send(info_requested)
37
+ end
38
+ end
30
39
  end
31
40
 
32
41
  # English aliases
@@ -42,6 +51,10 @@ module Brasil
42
51
 
43
52
  private
44
53
 
54
+ def self.valid_info?(info_requested)
55
+ !info_requested || self.instance_methods.include?(info_requested.to_sym)
56
+ end
57
+
45
58
  def self.sanitize(regiao)
46
59
  regiao.downcase.capitalize.sub("-o", "-O")
47
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brasil-estados
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Fleury