Class: FreightKit::Location
- Defined in:
- lib/freight_kit/models/location.rb
Overview
Class representing a location.
Constant Summary collapse
- TYPES =
%i[commercial po_box residential].freeze
Instance Attribute Summary collapse
-
#address1 ⇒ String?
The first street line.
-
#address2 ⇒ String?
The second street line.
-
#address3 ⇒ String?
The third street line.
-
#city ⇒ String?
The city name.
-
#contact ⇒ String?
The contact at the location.
-
#country ⇒ ActiveUtils::Country?
The country of the location.
-
#lat ⇒ BigNum?
The latitude of the location.
-
#lng ⇒ BigNum?
The longitude of the location.
-
#postal_code ⇒ String?
The postal code (or ZIP® code) of the location.
-
#province ⇒ String?
The province (or state/territory) abbreviation of the location.
-
#type ⇒ Symbol?
The type of the location.
Instance Method Summary collapse
Methods inherited from Model
Constructor Details
This class inherits a constructor from FreightKit::Model
Instance Attribute Details
#address1 ⇒ String?
The first street line
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#address2 ⇒ String?
The second street line
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#address3 ⇒ String?
The third street line
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#city ⇒ String?
The city name.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#contact ⇒ String?
The contact at the location.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#country ⇒ ActiveUtils::Country?
The country of the location.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#lat ⇒ BigNum?
The latitude of the location.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#lng ⇒ BigNum?
The longitude of the location.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#postal_code ⇒ String?
The postal code (or ZIP® code) of the location.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#province ⇒ String?
The province (or state/territory) abbreviation of the location.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
#type ⇒ Symbol?
The type of the location.
It should be one of: :commercial, :po_box, :residential
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/freight_kit/models/location.rb', line 53 class Location < Model TYPES = %i[commercial po_box residential].freeze attr_accessor :address1, :address2, :address3, :city, :postal_code, :province attr_reader :contact, :country, :lat, :lng, :type def contact=(contact) return @contact = nil if contact.blank? raise ArgumentError, 'contact must be a Contact' unless contact.is_a?(FreightKit::Contact) @contact = contact end def country=(country) return country = nil if country.blank? if country.is_a?(ActiveUtils::Country) @country = country return country end raise ArgumentError, 'country must be an ActiveUtils::Country' end def lat=(num) return @lat = nil if num.blank? return @lat = num if num.is_a?(BigNum) raise ArgumentError, 'lat must be a BigNum' end def lng=(num) return @lng = nil if num.blank? return @lng = num if num.is_a?(BigNum) raise ArgumentError, 'lng must be a BigNum' end def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end def type=(value) return @type = nil if value.blank? raise ArgumentError, "type must be one of :#{TYPES.join(", :")}" if TYPES.exclude?(value) @type = value end end |
Instance Method Details
#time_zone ⇒ Object
94 95 96 97 98 |
# File 'lib/freight_kit/models/location.rb', line 94 def time_zone return if country&.code(:alpha2)&.blank? || province.blank? || city.blank? PlaceKit.lookup(country.code(:alpha2).to_s, province, city) end |