Class: ODDB::Address

Inherits:
Object show all
Defined in:
src/model/address.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Address) initialize

A new instance of Address



11
12
13
# File 'src/model/address.rb', line 11

def initialize
  @lines = []
end

Instance Attribute Details

- (Object) city

Returns the value of attribute city



9
10
11
12
13
# File 'src/model/address.rb', line 9

def city
  if(match =/[^0-9]+/u.match(self.lines[-1]))
     match.to_s.strip
  end
end

- (Object) fax

Returns the value of attribute fax



9
10
11
# File 'src/model/address.rb', line 9

def fax
  @fax
end

- (Object) fon

Returns the value of attribute fon



9
10
11
# File 'src/model/address.rb', line 9

def fon
  @fon
end

- (Object) lines

Returns the value of attribute lines



9
10
11
# File 'src/model/address.rb', line 9

def lines
  @lines.delete_if { |line| line.strip.empty? }
end

- (Object) plz

Returns the value of attribute plz



9
10
11
12
13
# File 'src/model/address.rb', line 9

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

- (Object) type

Returns the value of attribute type



9
10
11
# File 'src/model/address.rb', line 9

def type
  @type
end

Instance Method Details

- (Object) <=>(other)



45
46
47
# File 'src/model/address.rb', line 45

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

- (Object) lines_without_title



22
23
24
25
26
# File 'src/model/address.rb', line 22

def lines_without_title
  self.lines.select { |line|
    !/(Prof(\.|ess))|(dr\.\s*med)|(Docteur)/iu.match(line)
  }
end

- (Object) number



27
28
29
30
31
# File 'src/model/address.rb', line 27

def number 
  if(match = /[0-9][^,]*/u.match(self.lines[-2]))
    match.to_s.strip
  end
end

- (Object) search_terms



37
38
39
# File 'src/model/address.rb', line 37

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

- (Object) street



40
41
42
43
44
# File 'src/model/address.rb', line 40

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