Class: CepFacil::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/cep_facil/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zip_code, type, city, state, neighborhood, street) ⇒ Address

Returns a new instance of Address.



31
32
33
34
35
36
37
38
# File 'lib/cep_facil/api.rb', line 31

def initialize(zip_code, type, city, state, neighborhood, street)
  @zip_code = zip_code
  @type = type
  @city = city
  @state = state
  @neighborhood = neighborhood
  @street = street
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



29
30
31
# File 'lib/cep_facil/api.rb', line 29

def city
  @city
end

#neighborhoodObject

Returns the value of attribute neighborhood.



29
30
31
# File 'lib/cep_facil/api.rb', line 29

def neighborhood
  @neighborhood
end

#stateObject

Returns the value of attribute state.



29
30
31
# File 'lib/cep_facil/api.rb', line 29

def state
  @state
end

#streetObject

Returns the value of attribute street.



29
30
31
# File 'lib/cep_facil/api.rb', line 29

def street
  @street
end

#typeObject

Returns the value of attribute type.



29
30
31
# File 'lib/cep_facil/api.rb', line 29

def type
  @type
end

#zip_codeObject

Returns the value of attribute zip_code.



29
30
31
# File 'lib/cep_facil/api.rb', line 29

def zip_code
  @zip_code
end

Instance Method Details

#full_formatObject

Returns the address in its extense format



47
48
49
# File 'lib/cep_facil/api.rb', line 47

def full_format
  "#{self.type} #{self.street}, #{self.city} - #{self.state} #{self.zip_code}, Brasil"
end

#valid?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
# File 'lib/cep_facil/api.rb', line 40

def valid?
  answ = false
  answ = true if (self.zip_code && type && city)
  return true
end