Class: TurkishCities

Inherits:
Object
  • Object
show all
Defined in:
lib/turkish_cities.rb,
lib/turkish_cities/version.rb

Constant Summary collapse

PLATE_NUMBER =
'plate_number'
PHONE_CODE =
'phone_code'
VERSION =
'0.7.0'

Class Method Summary collapse

Class Method Details

.change_locale(language_code) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/turkish_cities.rb', line 20

def self.change_locale(language_code)
  if %w[en tr].include?(language_code)
    I18n.locale = language_code.to_sym
    return I18n.t('language.success')
  end
  I18n.t('language.errors.unsupported_language_code')
end

.distance_between(from, to, travel_method) ⇒ Object



52
53
54
# File 'lib/turkish_cities.rb', line 52

def self.distance_between(from, to, travel_method)
  Distance.new(from, to, travel_method).distance_between
end

.find_by_elevation(type, elevation_one, elevation_two = nil) ⇒ Object



64
65
66
# File 'lib/turkish_cities.rb', line 64

def self.find_by_elevation(type, elevation_one, elevation_two = nil)
  Elevation.new.find_by_elevation(type, elevation_one, elevation_two)
end

.find_by_population(type, population_one, population_two = nil) ⇒ Object



68
69
70
# File 'lib/turkish_cities.rb', line 68

def self.find_by_population(type, population_one, population_two = nil)
  Population.new.find_by_population(type, population_one, population_two)
end

.find_by_postcode(postcode) ⇒ Object



72
73
74
# File 'lib/turkish_cities.rb', line 72

def self.find_by_postcode(postcode)
  Postcode.new.find_by_postcode(postcode)
end

.find_name_by_phone_code(phone_code) ⇒ Object



32
33
34
# File 'lib/turkish_cities.rb', line 32

def self.find_name_by_phone_code(phone_code)
  City.new.find_by_phone_code(phone_code)
end

.find_name_by_plate_number(plate_number) ⇒ Object



28
29
30
# File 'lib/turkish_cities.rb', line 28

def self.find_name_by_plate_number(plate_number)
  City.new.find_by_id(plate_number)
end

.find_phone_code_by_name(city_name) ⇒ Object



40
41
42
# File 'lib/turkish_cities.rb', line 40

def self.find_phone_code_by_name(city_name)
  City.new.find_by_name(city_name, self::PHONE_CODE)
end

.find_plate_number_by_name(city_name) ⇒ Object



36
37
38
# File 'lib/turkish_cities.rb', line 36

def self.find_plate_number_by_name(city_name)
  City.new.find_by_name(city_name, self::PLATE_NUMBER)
end

.list_cities(options = {}) ⇒ Object



44
45
46
# File 'lib/turkish_cities.rb', line 44

def self.list_cities(options = {})
  City.new.list_cities(options)
end

.list_districts(city_name) ⇒ Object



48
49
50
# File 'lib/turkish_cities.rb', line 48

def self.list_districts(city_name)
  City.new.list_districts(city_name)
end

.list_neighborhoods(city_name, district_name, subdistrict_name = nil) ⇒ Object



60
61
62
# File 'lib/turkish_cities.rb', line 60

def self.list_neighborhoods(city_name, district_name, subdistrict_name = nil)
  District.new(city_name, district_name).neighborhoods(subdistrict_name)
end

.list_subdistricts(city_name, district_name) ⇒ Object



56
57
58
# File 'lib/turkish_cities.rb', line 56

def self.list_subdistricts(city_name, district_name)
  District.new(city_name, district_name).subdistricts
end