Class: Garbanzo::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/garbanzo/address.rb

Constant Summary collapse

ATTRIBUTES =
[
  :first_name,
  :last_name,
  :company,
  :address1,
  :address2,
  :city,
  :state,
  :zip,
  :country
]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Address

Returns a new instance of Address.



17
18
19
20
21
# File 'lib/garbanzo/address.rb', line 17

def initialize(options = {})
  options.each do |attribute, value|
    public_send("#{attribute}=", value)
  end
end

Instance Method Details

#to_hObject



27
28
29
30
31
32
33
# File 'lib/garbanzo/address.rb', line 27

def to_h
  ATTRIBUTES.reduce({}) do |hash, attribute|
    value = public_send(attribute)
    hash.merge!(attribute => value) if value
    hash
  end
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/garbanzo/address.rb', line 23

def valid?
  first_name.to_s != '' && last_name.to_s != ''
end