Class: EVSS::PCIUAddress::Address
- Inherits:
-
Object
- Object
- EVSS::PCIUAddress::Address
- Includes:
- ActiveModel::Serialization, ActiveModel::Validations
- Defined in:
- lib/evss/pciu_address/address.rb
Overview
Model for PCIU address
Direct Known Subclasses
Constant Summary collapse
- ADDRESS_TYPES =
{ domestic: 'DOMESTIC', international: 'INTERNATIONAL', military: 'MILITARY' }.freeze
- ZIP_CODE_REGEX =
/\A\d{5}\z/
- ZIP_SUFFIX_REGEX =
/\A-?\d{4}\z/
Instance Attribute Summary collapse
-
#address_effective_date ⇒ DateTime
The date at which the address is known to be valid.
-
#address_one ⇒ String
The first line of the address (max 35 characters).
-
#address_three ⇒ String
The third line of the address (max 35 characters).
-
#address_two ⇒ String
The second line of the address (max 35 characters).
-
#type ⇒ String
Address type; one of %w[DOMESTIC INTERNATIONAL MILITARY].
Instance Attribute Details
#address_effective_date ⇒ DateTime
Returns The date at which the address is known to be valid.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/evss/pciu_address/address.rb', line 22 class Address include ActiveModel::Validations include ActiveModel::Serialization include Virtus.model(nullify_blank: true) ADDRESS_TYPES = { domestic: 'DOMESTIC', international: 'INTERNATIONAL', military: 'MILITARY' }.freeze ZIP_CODE_REGEX = /\A\d{5}\z/ ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/ attribute :type, String attribute :address_effective_date, DateTime attribute :address_one, String attribute :address_two, String attribute :address_three, String validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 } validates :address_two, pciu_address_line: true, length: { maximum: 35 } validates :address_three, pciu_address_line: true, length: { maximum: 35 } validates :type, inclusion: { in: ADDRESS_TYPES.values } end |
#address_one ⇒ String
Returns The first line of the address (max 35 characters).
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/evss/pciu_address/address.rb', line 22 class Address include ActiveModel::Validations include ActiveModel::Serialization include Virtus.model(nullify_blank: true) ADDRESS_TYPES = { domestic: 'DOMESTIC', international: 'INTERNATIONAL', military: 'MILITARY' }.freeze ZIP_CODE_REGEX = /\A\d{5}\z/ ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/ attribute :type, String attribute :address_effective_date, DateTime attribute :address_one, String attribute :address_two, String attribute :address_three, String validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 } validates :address_two, pciu_address_line: true, length: { maximum: 35 } validates :address_three, pciu_address_line: true, length: { maximum: 35 } validates :type, inclusion: { in: ADDRESS_TYPES.values } end |
#address_three ⇒ String
Returns The third line of the address (max 35 characters).
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/evss/pciu_address/address.rb', line 22 class Address include ActiveModel::Validations include ActiveModel::Serialization include Virtus.model(nullify_blank: true) ADDRESS_TYPES = { domestic: 'DOMESTIC', international: 'INTERNATIONAL', military: 'MILITARY' }.freeze ZIP_CODE_REGEX = /\A\d{5}\z/ ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/ attribute :type, String attribute :address_effective_date, DateTime attribute :address_one, String attribute :address_two, String attribute :address_three, String validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 } validates :address_two, pciu_address_line: true, length: { maximum: 35 } validates :address_three, pciu_address_line: true, length: { maximum: 35 } validates :type, inclusion: { in: ADDRESS_TYPES.values } end |
#address_two ⇒ String
Returns The second line of the address (max 35 characters).
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/evss/pciu_address/address.rb', line 22 class Address include ActiveModel::Validations include ActiveModel::Serialization include Virtus.model(nullify_blank: true) ADDRESS_TYPES = { domestic: 'DOMESTIC', international: 'INTERNATIONAL', military: 'MILITARY' }.freeze ZIP_CODE_REGEX = /\A\d{5}\z/ ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/ attribute :type, String attribute :address_effective_date, DateTime attribute :address_one, String attribute :address_two, String attribute :address_three, String validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 } validates :address_two, pciu_address_line: true, length: { maximum: 35 } validates :address_three, pciu_address_line: true, length: { maximum: 35 } validates :type, inclusion: { in: ADDRESS_TYPES.values } end |
#type ⇒ String
Returns Address type; one of %w[DOMESTIC INTERNATIONAL MILITARY].
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/evss/pciu_address/address.rb', line 22 class Address include ActiveModel::Validations include ActiveModel::Serialization include Virtus.model(nullify_blank: true) ADDRESS_TYPES = { domestic: 'DOMESTIC', international: 'INTERNATIONAL', military: 'MILITARY' }.freeze ZIP_CODE_REGEX = /\A\d{5}\z/ ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/ attribute :type, String attribute :address_effective_date, DateTime attribute :address_one, String attribute :address_two, String attribute :address_three, String validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 } validates :address_two, pciu_address_line: true, length: { maximum: 35 } validates :address_three, pciu_address_line: true, length: { maximum: 35 } validates :type, inclusion: { in: ADDRESS_TYPES.values } end |