Module: SerbiaZipCodes

Defined in:
lib/serbia_zip_codes.rb

Class Method Summary collapse

Class Method Details

.find_by_city(city = nil) ⇒ Array

Search for zip code by city

Parameters:

  • city (String) (defaults to: nil)

    city name in string format

Returns:

  • (Array)

    result as array of hashes



18
19
20
# File 'lib/serbia_zip_codes.rb', line 18

def self.find_by_city(city = nil)
  @data.select { |d| d["city"].match /#{city}/i }
end

.find_by_zip(zip = nil) ⇒ Array

Search for city by zip code

Parameters:

  • zip (String) (defaults to: nil)

    zip code in string format

Returns:

  • (Array)

    result as array of hashes



10
11
12
# File 'lib/serbia_zip_codes.rb', line 10

def self.find_by_zip(zip = nil)
  @data.select { |d| d["zip_code"].match /#{zip}/i }
end