Class: Xpost::Address

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/xpost/address.rb

Constant Summary collapse

REQUIRED_ADDRESS_PARAMETERS =
Set[:name, :line_1, :city, :state, :postal_code, :country]
OPTIONAL_ADDRESS_PARAMETERS =
Set[:company, :title, :email, :phone_number, :mobile_number, :fax_number,
:district, :line_2, :remarks]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Address



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/xpost/address.rb', line 17

def initialize(options = {})
  # (?) Mr., Mrs., Ms., etc.
  @title          = options[:title]
  @name           = options[:name]
  @email          = options[:email]
  @phone_number   = options[:phone_number]
  @mobile_number  = options[:mobile_number]
  @fax_number     = options[:fax_number]
  @company        = options[:company]

  # Address Line 1
  @line_1         = options[:line_1]
  # Address Line 1
  @line_2         = options[:line_2]
  # City
  @city           = options[:city]
  # District (NCR's Four Districts) (Optional)
  @district       = options[:district]
  # State / Province
  @state          = options[:state]
  # Postal Code / ZIP Code
  @postal_code    = options[:postal_code]
  # Country
  @country        = options[:country]

  @remarks        = options[:remarks]
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



12
13
14
# File 'lib/xpost/address.rb', line 12

def city
  @city
end

#companyObject

Returns the value of attribute company.



13
14
15
# File 'lib/xpost/address.rb', line 13

def company
  @company
end

#countryObject

Returns the value of attribute country.



12
13
14
# File 'lib/xpost/address.rb', line 12

def country
  @country
end

#districtObject

Returns the value of attribute district.



13
14
15
# File 'lib/xpost/address.rb', line 13

def district
  @district
end

#emailObject

Returns the value of attribute email.



13
14
15
# File 'lib/xpost/address.rb', line 13

def email
  @email
end

#fax_numberObject

Returns the value of attribute fax_number.



13
14
15
# File 'lib/xpost/address.rb', line 13

def fax_number
  @fax_number
end

#line_1Object

Returns the value of attribute line_1.



12
13
14
# File 'lib/xpost/address.rb', line 12

def line_1
  @line_1
end

#line_2Object

Returns the value of attribute line_2.



13
14
15
# File 'lib/xpost/address.rb', line 13

def line_2
  @line_2
end

#mobile_numberObject

Returns the value of attribute mobile_number.



13
14
15
# File 'lib/xpost/address.rb', line 13

def mobile_number
  @mobile_number
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/xpost/address.rb', line 12

def name
  @name
end

#phone_numberObject

Returns the value of attribute phone_number.



13
14
15
# File 'lib/xpost/address.rb', line 13

def phone_number
  @phone_number
end

#postal_codeObject

Returns the value of attribute postal_code.



12
13
14
# File 'lib/xpost/address.rb', line 12

def postal_code
  @postal_code
end

#remarksObject

Returns the value of attribute remarks.



13
14
15
# File 'lib/xpost/address.rb', line 13

def remarks
  @remarks
end

#stateObject

Returns the value of attribute state.



12
13
14
# File 'lib/xpost/address.rb', line 12

def state
  @state
end

#titleObject

Returns the value of attribute title.



13
14
15
# File 'lib/xpost/address.rb', line 13

def title
  @title
end

Class Method Details

.sample_addressObject



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/xpost/address.rb', line 65

def self.sample_address
  address = Xpost::Address.new(
    name: "Bobby Axelrod",
    line_1: "EDSA Shangri-La",
    city: "Mandaluyong",
    state: "Metro Manila",
    postal_code: "1650",
    country: "PH"
  )
  address
end

Instance Method Details

#attributesObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/xpost/address.rb', line 45

def attributes
  {
    title: self.title,
    name: self.name,
    email: self.email,
    phone_number: self.phone_number,
    mobile_number: self.mobile_number,
    fax_number: self.fax_number,
    company: self.company,
    line_1: self.line_1,
    line_2: self.line_2,
    city: self.city,
    district: self.district,
    state: self.state,
    postal_code: self.postal_code,
    country: self.country,
    remarks: self.remarks
  }
end