Class: ODDB::Address2

Inherits:
Object show all
Includes:
OddbYaml, PersistenceMethods
Defined in:
src/model/address.rb,
ext/export/src/oddb_yaml.rb

Direct Known Subclasses

AddressSuggestion

Constant Summary

EXPORT_PROPERTIES =
[
  '@title',
  '@name',
  '@additional_lines',
  '@address',
  '@location',
  '@canton',
  '@fon',
  '@fax',
  '@type',
]
@@city_pattern =
/[^0-9]+[^0-9\-](?!-)([0-9]+)?/u

Constants included from OddbYaml

EXPORT_PROPERTIES, YAML_URI

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from OddbYaml

#to_yaml_properties, #to_yaml_type

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #init, #nil_if_empty, #parent, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (Address2) initialize

A new instance of Address2



57
58
59
60
61
62
# File 'src/model/address.rb', line 57

def initialize 
  super
  @additional_lines = []
  @fon = []
  @fax = []
end

Instance Attribute Details

- (Object) additional_lines

Returns the value of attribute additional_lines



52
53
54
# File 'src/model/address.rb', line 52

def additional_lines
  @additional_lines
end

- (Object) address

Returns the value of attribute address



52
53
54
# File 'src/model/address.rb', line 52

def address
  @address
end

- (Object) canton

Returns the value of attribute canton



52
53
54
# File 'src/model/address.rb', line 52

def canton
  @canton
end

- (Object) fax

Returns the value of attribute fax



52
53
54
# File 'src/model/address.rb', line 52

def fax
  @fax
end

- (Object) fon

Returns the value of attribute fon



52
53
54
# File 'src/model/address.rb', line 52

def fon
  @fon
end

- (Object) location

Returns the value of attribute location



52
53
54
# File 'src/model/address.rb', line 52

def location
  @location
end

- (Object) name Also known as: contact, pointer_descr

Returns the value of attribute name



52
53
54
# File 'src/model/address.rb', line 52

def name
  @name
end

- (Object) title

Returns the value of attribute title



52
53
54
# File 'src/model/address.rb', line 52

def title
  @title
end

- (Object) type Also known as: address_type

Returns the value of attribute type



52
53
54
# File 'src/model/address.rb', line 52

def type
  @type
end

Instance Method Details

- (Object) <=>(other)



124
125
126
# File 'src/model/address.rb', line 124

def <=>(other)
  self.lines <=> other.lines
end

- (Object) city



63
64
65
66
67
# File 'src/model/address.rb', line 63

def city
  if(match = @@city_pattern.match(@location.to_s))
     match.to_s.strip
  end
end

- (Object) lines



79
80
81
82
83
84
85
# File 'src/model/address.rb', line 79

def lines
  lines = lines_without_title
  if(!@title.to_s.empty?)
    lines.unshift(@title)
  end
  lines
end

- (Object) lines_without_title



86
87
88
89
90
91
92
93
94
# File 'src/model/address.rb', line 86

def lines_without_title
  ([
    @name,
  ] + @additional_lines +
  [
    @address,
    location_canton,
  ]).delete_if { |line| line.to_s.empty? }
end

- (Object) location_canton



95
96
97
98
99
100
101
# File 'src/model/address.rb', line 95

def location_canton
  if(@canton && @location)
    @location + " (#{@canton})"
  else
    @location
  end
end

- (Object) number



102
103
104
105
106
# File 'src/model/address.rb', line 102

def number 
  if(match = /[0-9][^\s,]*/u.match(@address.to_s))
    match.to_s.strip
  end
end

- (Object) plz



107
108
109
110
111
# File 'src/model/address.rb', line 107

def plz
  if(match = /[1-9][0-9]{3}/u.match(@location.to_s))
     match.to_s
  end
end

- (Object) replace_with(other)



68
69
70
71
72
73
74
75
76
77
78
# File 'src/model/address.rb', line 68

def replace_with(other)
  @name = other.name
  @title = other.title
  @additional_lines = other.additional_lines
  @address = other.address
  @location = other.location
  @fon = other.fon
  @fax = other.fax
  @canton = other.canton
  @type = other.type
end

- (Object) search_terms



112
113
114
115
# File 'src/model/address.rb', line 112

def search_terms
  ODDB.search_terms([self.lines_without_title, @fon, @fax, 
    self.city, self.plz])
end

- (Object) street



116
117
118
119
120
# File 'src/model/address.rb', line 116

def street
  if(match = /[^0-9,]+/u.match(@address.to_s))
    match.to_s.strip
  end
end

- (Object) ydim_lines



121
122
123
# File 'src/model/address.rb', line 121

def ydim_lines
  [@address].concat(@additional_lines)
end