Module: Urbans

Defined in:
lib/urbans.rb,
lib/urbans/version.rb

Defined Under Namespace

Classes: City, Configurer, Country, Error, Province

Constant Summary collapse

URBAN_PATH =
File.expand_path(File.dirname(__FILE__)) + "/"
ALL_COUNTRIES =

all avalable countries supported by Urbans

[:id]
ALL_LOCALES =

all available locales

[:id, :en]
COUNTRIES =

mapping of countries and locales, eg:

id: {en: Indonesia, id: Indonesia

} only load locale when necessary

{}
PROVINCES =

mapping of provinces and locales, eg:

id_pv_ach: {en: "Aceh", id: "Aceh"

} only load locale when necessary

{}
CITIES =

similar to above

{}
VERSION =
"0.1.0"
@@default_locale =
nil

Class Method Summary collapse

Class Method Details

.cityObject



69
70
71
# File 'lib/urbans.rb', line 69

def city
  Urbans::City
end

.config(&block) ⇒ Object



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

def config(&block)
  Urbans::Configurer.new.instance_eval(&block)
end

.countryObject



61
62
63
# File 'lib/urbans.rb', line 61

def country
  Urbans::Country
end

.localeObject

Raises:



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

def locale
  raise Urbans::Error, "Locale have not been set yet" if @@default_locale.nil?
  @@default_locale
end

.locale=(locale) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/urbans.rb', line 48

def locale=(locale)
  if ALL_LOCALES.include?(locale.to_sym)
    @@default_locale = locale.to_sym
  else
    raise Urbans::Error, "Unsupported locale: #{locale}."
  end
end

.provinceObject



65
66
67
# File 'lib/urbans.rb', line 65

def province
  Urbans::Province
end