Class: AddressLabel
- Inherits:
-
Object
- Object
- AddressLabel
- Defined in:
- app/models/address_label.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#company ⇒ Object
Returns the value of attribute company.
-
#country ⇒ Object
Returns the value of attribute country.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_prefix ⇒ Object
Returns the value of attribute name_prefix.
-
#name_suffix ⇒ Object
Returns the value of attribute name_suffix.
-
#personal_title ⇒ Object
Returns the value of attribute personal_title.
-
#postal_address ⇒ Object
Returns the value of attribute postal_address.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#text_above_name ⇒ Object
Returns the value of attribute text_above_name.
-
#text_below_name ⇒ Object
Returns the value of attribute text_below_name.
Instance Method Summary collapse
-
#initialize(name, address_field, name_surrounding_field, personal_title = '', company = '') ⇒ AddressLabel
constructor
A new instance of AddressLabel.
- #postal_address_with_name_surrounding ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, address_field, name_surrounding_field, personal_title = '', company = '') ⇒ AddressLabel
Returns a new instance of AddressLabel.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/address_label.rb', line 8 def initialize(name, address_field, name_surrounding_field, personal_title = '', company = '') self.name = name self.company = company self.postal_address = address_field.try(:value) self.postal_code = address_field.try(:postal_code) self.country_code = address_field.try(:country_code) self.country = address_field.try(:geo_location).try(:country) self.city = address_field.try(:geo_location).try(:city) self.text_above_name = name_surrounding_field.try(:text_above_name).try(:strip) self.text_below_name = name_surrounding_field.try(:text_below_name).try(:strip) self.name_prefix = name_surrounding_field.try(:name_prefix).try(:strip) self.name_suffix = name_surrounding_field.try(:name_suffix).try(:strip) self.personal_title = personal_title end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city
4 5 6 |
# File 'app/models/address_label.rb', line 4 def city @city end |
#company ⇒ Object
Returns the value of attribute company
3 4 5 |
# File 'app/models/address_label.rb', line 3 def company @company end |
#country ⇒ Object
Returns the value of attribute country
4 5 6 |
# File 'app/models/address_label.rb', line 4 def country @country end |
#country_code ⇒ Object
Returns the value of attribute country_code
4 5 6 |
# File 'app/models/address_label.rb', line 4 def country_code @country_code end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'app/models/address_label.rb', line 2 def name @name end |
#name_prefix ⇒ Object
Returns the value of attribute name_prefix
5 6 7 |
# File 'app/models/address_label.rb', line 5 def name_prefix @name_prefix end |
#name_suffix ⇒ Object
Returns the value of attribute name_suffix
5 6 7 |
# File 'app/models/address_label.rb', line 5 def name_suffix @name_suffix end |
#personal_title ⇒ Object
Returns the value of attribute personal_title
6 7 8 |
# File 'app/models/address_label.rb', line 6 def personal_title @personal_title end |
#postal_address ⇒ Object
Returns the value of attribute postal_address
4 5 6 |
# File 'app/models/address_label.rb', line 4 def postal_address @postal_address end |
#postal_code ⇒ Object
Returns the value of attribute postal_code
4 5 6 |
# File 'app/models/address_label.rb', line 4 def postal_code @postal_code end |
#text_above_name ⇒ Object
Returns the value of attribute text_above_name
5 6 7 |
# File 'app/models/address_label.rb', line 5 def text_above_name @text_above_name end |
#text_below_name ⇒ Object
Returns the value of attribute text_below_name
5 6 7 |
# File 'app/models/address_label.rb', line 5 def text_below_name @text_below_name end |
Instance Method Details
#postal_address_with_name_surrounding ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/address_label.rb', line 27 def postal_address_with_name_surrounding # text_before_the_name = name_prefix || "" # text_before_the_name += " #{personal_title}" if name_prefix != personal_title # ("#{text_above_name}\n" + # "#{text_before_the_name} #{name} #{name_suffix}\n" + # "#{text_below_name}\n" + # (postal_address || "") # ) ( "#{text_above_name}\n" + "#{name_prefix} #{name} #{name_suffix}\n" + "#{text_below_name}\n" + "#{company}\n" + (postal_address || "") ) .gsub(' ', ' ') .gsub("\n\n\n", "\n") .gsub("\n\n", "\n") .gsub(" \n", "\n") .gsub("\n ", "\n") .strip end |
#to_s ⇒ Object
23 24 25 |
# File 'app/models/address_label.rb', line 23 def to_s postal_address_with_name_surrounding end |