Class: FruitToLime::Address
- Inherits:
-
Object
- Object
- FruitToLime::Address
- Includes:
- SerializeHelper
- Defined in:
- lib/fruit_to_lime/model/address.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#location ⇒ Object
Returns the value of attribute location.
-
#street ⇒ Object
Returns the value of attribute street.
-
#zip_code ⇒ Object
Returns the value of attribute zip_code.
Instance Method Summary collapse
- #country_name ⇒ Object
- #country_name=(name) ⇒ Object
- #get_import_rows ⇒ Object
-
#initialize ⇒ Address
constructor
A new instance of Address.
- #parse_zip_and_address_se(line) ⇒ Object
- #serialize_variables ⇒ Object
Methods included from SerializeHelper
get_import_rows, #map_symbol_to_row, #map_to_row, serialize, #serialize, #serialize_to_file, serialize_to_file, serialize_variables, #symbol_to_name
Constructor Details
#initialize ⇒ Address
Returns a new instance of Address.
9 10 |
# File 'lib/fruit_to_lime/model/address.rb', line 9 def initialize() end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
4 5 6 |
# File 'lib/fruit_to_lime/model/address.rb', line 4 def city @city end |
#country_code ⇒ Object
Returns the value of attribute country_code.
4 5 6 |
# File 'lib/fruit_to_lime/model/address.rb', line 4 def country_code @country_code end |
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/fruit_to_lime/model/address.rb', line 4 def location @location end |
#street ⇒ Object
Returns the value of attribute street.
4 5 6 |
# File 'lib/fruit_to_lime/model/address.rb', line 4 def street @street end |
#zip_code ⇒ Object
Returns the value of attribute zip_code.
4 5 6 |
# File 'lib/fruit_to_lime/model/address.rb', line 4 def zip_code @zip_code end |
Instance Method Details
#country_name ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/fruit_to_lime/model/address.rb', line 17 def country_name if @country_code IsoCountryCodes.find(@country_code).name else nil end end |
#country_name=(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fruit_to_lime/model/address.rb', line 24 def country_name=(name) @country_code = case name when nil nil when 'Sverige' 'SE' else IsoCountryCodes.search_by_name(name).first.alpha2 end end |
#get_import_rows ⇒ Object
12 13 14 15 16 |
# File 'lib/fruit_to_lime/model/address.rb', line 12 def get_import_rows (serialize_variables+[{:id=>:country_name, :type=>:string}]).map do |p| map_to_row p end end |
#parse_zip_and_address_se(line) ⇒ Object
34 35 36 |
# File 'lib/fruit_to_lime/model/address.rb', line 34 def parse_zip_and_address_se(line) FruitToLime::AddressHelper::parse_line_to_zip_and_address_se(line, self) end |
#serialize_variables ⇒ Object
5 6 7 |
# File 'lib/fruit_to_lime/model/address.rb', line 5 def serialize_variables [ :street, :zip_code, :city, :country_code, :location].map {|p| {:id=>p,:type=>:string} } end |