Class: Typename

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/ruby-opengeodb/location.rb

Overview

class

Instance Method Summary collapse

Instance Method Details

#name_for(type_no) ⇒ Object



44
45
46
47
# File 'lib/ruby-opengeodb/location.rb', line 44

def name_for(type_no)
  rec = Typename.find(:first, :conditions => "type_id = #{type_no}")
  rec.attributes['name']
end

#type_id(type) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ruby-opengeodb/location.rb', line 26

def type_id(type)
  case type
  when :postleitzahl,:plz
    typename = Typename.find(:first, :conditions => "name = 'Postleitzahl' AND type_locale = 'de'")
  when :postleitzahlgebiet
    typename = Typename.find(:first, :conditions => "name = 'Postleitzahlgebiet' AND type_locale = 'de'")
  when :kfz_kennzeichen
    typename = Typename.find(:first, :conditions => "name = 'KFZ-Kennzeichen' AND type_locale = 'de'")
  when :kanton
    typename = Typename.find(:first, :conditions => "name = 'Kanton' AND type_locale = 'de_CH'")
  when :ortsname
    typename = Typename.find(:first, :conditions => "name = 'Name' AND type_locale = 'de'")
  else
    raise 'invalid type: '+type.to_s
  end
  return typename.attributes['type_id']
end