Class: Pinpoint::Address

Inherits:
Object
  • Object
show all
Includes:
Mapable
Defined in:
lib/pinpoint/address.rb

Constant Summary collapse

ATTRIBUTE_NAMES =
[
  :name,
  :street_and_premises,
  :city,
  :state,
  :county,
  :postal_code,
  :country,
  :latitude,
  :longitude,
]

Instance Method Summary collapse

Methods included from Mapable

#map_url

Constructor Details

#initialize(options = {}) ⇒ Address

Returns a new instance of Address.



46
47
48
49
50
# File 'lib/pinpoint/address.rb', line 46

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

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
58
# File 'lib/pinpoint/address.rb', line 52

def complete?
  present?(street_and_premises) &&
  present?(city)                &&
  present?(state)               &&
  present?(postal_code)         &&
  present?(country)
end

#empty?Boolean

Returns:

  • (Boolean)


64
65
66
67
68
69
70
# File 'lib/pinpoint/address.rb', line 64

def empty?
  blank?(street_and_premises) &&
  blank?(city)                &&
  blank?(state)               &&
  blank?(postal_code)         &&
  blank?(country)
end

#incomplete?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/pinpoint/address.rb', line 60

def incomplete?
  !complete? && !empty?
end

#to_s(options = { country: :us, format: :one_line }) ⇒ Object



72
73
74
# File 'lib/pinpoint/address.rb', line 72

def to_s(options = { country: :us, format: :one_line })
  Formatter.format(self, options)
end