brasil-estados 0.1.1 → 0.2.0

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 +18 -35
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78c2620f5184bfb72dd6b8af443156046ca773e8
4
- data.tar.gz: 5cd7fd5dbc7756f89b4126935306d9119435a0e1
3
+ metadata.gz: f30bf3956863970deb8cea4442d5978e9c755bb3
4
+ data.tar.gz: 87e7945d219da857dc00fcb3d6bfaf6296334e01
5
5
  SHA512:
6
- metadata.gz: e196e488e37704e4d1063d3890323f016be90148b5c221673ba5107cc18c112328c5faf21d01085dc0e4f36de8dfed3aa19de37e0c69d4eb5b602d402c375cc0
7
- data.tar.gz: ee220dd22578d12edc76e3b3480a512d97614ce6a64da6cfff380411e2d9e74ab65bf58a3b2ce02e8b972846593f3427704bf2be9d55c8321a77444b5a3c85fb
6
+ metadata.gz: 57b1a823a978bda3bab8813bad5255f4c5292d443f33587381a9d631ee621c0ad5faee3b712d804c9ec9cce6484907ae704f41d0927ca540aeb884c402388231
7
+ data.tar.gz: d352bbac9b701915ec9e1255ad3549c75585e932a862ba3f614ff9a2331c081575d1705de7d336c615f9cae8d7a61a0346728626fcfb32d4d5754645ce2fc28a
@@ -1,56 +1,40 @@
1
1
  module Brasil
2
- class Estado
2
+ class Estado
3
3
  attr_reader :nome, :sigla, :capital, :regiao
4
4
 
5
5
  def initialize(sigla)
6
6
  map_estado(sigla.to_sym)
7
7
  end
8
8
 
9
- def self.siglas
10
- ["AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO"]
11
- end
9
+ def self.siglas
10
+ ESTADOS.keys.map(&:to_s)
11
+ end
12
12
 
13
13
  def self.nomes
14
- ["Acre",
15
- "Alagoas",
16
- "Amapá",
17
- "Amazonas",
18
- "Bahia",
19
- "Ceará",
20
- "Distrito Federal",
21
- "Espírito Santo",
22
- "Goiás",
23
- "Maranhão",
24
- "Mato Grosso",
25
- "Mato Grosso do Sul",
26
- "Minas Gerais",
27
- "Pará",
28
- "Paraíba",
29
- "Paraná",
30
- "Pernambuco",
31
- "Piauí",
32
- "Rio de Janeiro",
33
- "Rio Grande do Norte",
34
- "Rio Grande do Sul",
35
- "Rondônia",
36
- "Roraima",
37
- "Santa Catarina",
38
- "São Paulo",
39
- "Sergipe",
40
- "Tocantins"]
14
+ ESTADOS.values.map { |estado| estado[:nome] }
41
15
  end
42
16
 
17
+ # English aliases
18
+ class <<self
19
+ alias_method :names, :nomes
20
+ alias_method :abbreviations, :siglas
21
+ end
22
+ alias_method :region, :regiao
23
+ alias_method :name, :nome
24
+ alias_method :region, :regiao
25
+ alias_method :abbreviation, :sigla
26
+
43
27
  private
44
28
 
45
29
  def map_estado(sigla)
46
- estado = mapper[sigla]
30
+ estado = ESTADOS[sigla]
47
31
  @nome = estado[:nome]
48
32
  @capital = estado[:capital]
49
33
  @regiao = estado[:regiao]
50
34
  @sigla = sigla.to_s
51
35
  end
52
36
 
53
- def mapper
37
+ ESTADOS =
54
38
  {
55
39
  AC: {
56
40
  nome: "Acre", capital: "Rio Branco", regiao: "Norte" },
@@ -107,6 +91,5 @@ module Brasil
107
91
  TO: {
108
92
  nome: "Tocantins", capital: "Palmas", regiao: "Norte" }
109
93
  }
110
- end
111
- end
94
+ end
112
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brasil-estados
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Fleury
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-27 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Brasil Estados is a Ruby Gem for accessing information about states from
14
14
  Brazil