Class: District

Inherits:
Object
  • Object
show all
Includes:
DecomposerHelper
Defined in:
lib/turkish_cities/district.rb

Instance Method Summary collapse

Methods included from DecomposerHelper

#check_input_range, #cities_not_found_error, #city_not_found_error, #city_population_not_found_error, #convert_chars, #create_district_list, #create_file_path, #district_not_found_error, #find_by_between, #postcode_not_found_error, #prepare_city_list, #sort_alphabetically, #sort_input_numbers, #subdistrict_not_found_error

Constructor Details

#initialize(city_name, district_name) ⇒ District

Returns a new instance of District.



11
12
13
14
15
# File 'lib/turkish_cities/district.rb', line 11

def initialize(city_name, district_name)
  @city_name = city_name
  @district_name = district_name
  @district_list = create_district_list(city_name)
end

Instance Method Details

#neighborhoods(subdistrict_name) ⇒ Object



23
24
25
26
27
28
# File 'lib/turkish_cities/district.rb', line 23

def neighborhoods(subdistrict_name)
  return district_not_found_error(@district_name, @city_name) if district_item.nil?

  neighborhoods = create_neighborhoods(subdistrict_name)
  neighborhoods.is_a?(Array) ? sort_alphabetically(neighborhoods) : neighborhoods
end

#subdistrictsObject



17
18
19
20
21
# File 'lib/turkish_cities/district.rb', line 17

def subdistricts
  return district_not_found_error(@district_name, @city_name) if district_item.nil?

  sort_alphabetically(district_item.keys)
end