class Medreg::Address2

Attributes

additional_lines[RW]
address[RW]
address_type[RW]
canton[RW]
fax[RW]
fon[RW]
location[RW]
name[RW]
title[RW]
type[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/medreg/address.rb, line 9
def initialize
  super
  @additional_lines = []
  @fon = []
  @fax = []
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/medreg/address.rb, line 63
def <=>(other)
  self.lines <=> other.lines
end
city() click to toggle source
# File lib/medreg/address.rb, line 15
def city
  @location
  if(match = @@city_pattern.match(@location.to_s))
     match.to_s.strip
  end
end
lines() click to toggle source
# File lib/medreg/address.rb, line 21
def lines
  lines = lines_without_title
  if(!@title.to_s.empty?)
    lines.unshift(@title)
  end
  lines
end
lines_without_title() click to toggle source
# File lib/medreg/address.rb, line 28
def lines_without_title
  ([
    @name,
  ] + @additional_lines +
  [
    @address,
    location_canton,
  ]).delete_if { |line| line.to_s.empty? }
end
location_canton() click to toggle source
# File lib/medreg/address.rb, line 37
def location_canton
  if(@canton && @location)
    @location + " (#{@canton})"
  else
    @location
  end
end
number() click to toggle source
# File lib/medreg/address.rb, line 44
def number
  if(match = /[0-9][^\s,]*/u.match(@address.to_s))
    match.to_s.strip
  elsif @additional_lines[-1]
    @additional_lines[-1].split(/\s/)[-1]
  end
end
plz() click to toggle source
# File lib/medreg/address.rb, line 51
def plz
  if(match = /[1-9][0-9]{3}/u.match(@location.to_s))
     match.to_s
  end
end
street() click to toggle source
# File lib/medreg/address.rb, line 56
def street
  if(match = /[^0-9,]+/u.match(@address.to_s))
    match.to_s.strip
  elsif @additional_lines[-1]
    @additional_lines[0].split(/\s/)[0]
  end
end