Class: Correios::Cep
- Inherits:
-
Object
- Object
- Correios::Cep
- Defined in:
- lib/ceps/cep.rb
Direct Known Subclasses
Constant Summary collapse
- Setup =
Correios::Setup.new
- AttrReaders =
[ :location, :type, :neighborhood, :city, :state ]
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(cep) ⇒ Cep
constructor
A new instance of Cep.
- #valid? ⇒ Boolean
Constructor Details
#initialize(cep) ⇒ Cep
Returns a new instance of Cep.
23 24 25 |
# File 'lib/ceps/cep.rb', line 23 def initialize(cep) @data = cep.is_a?(Hash) ? cep : Setup.ceps[cep] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
21 22 23 |
# File 'lib/ceps/cep.rb', line 21 def data @data end |
Class Method Details
.new(cep) ⇒ Object
39 40 41 42 43 |
# File 'lib/ceps/cep.rb', line 39 def new(cep) if cep.is_a?(Hash) || Setup.ceps.keys.include?(cep) super end end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'lib/ceps/cep.rb', line 31 def ==(other) other == data end |
#valid? ⇒ Boolean
27 28 29 |
# File 'lib/ceps/cep.rb', line 27 def valid? !(@data.nil? || @data.empty?) end |