Class: Pilipinas::City

Inherits:
Base
  • Object
show all
Defined in:
lib/pilipinas/city.rb

Overview

Represents a city or municipality of the Philippines.

Cities belong to a Province and contain one or more Barangay records.

Examples:

city = Pilipinas::City.find_by(name: "NAGA CITY")
city.barangays  # => [#<Barangay ...>, ...]

Instance Attribute Summary

Attributes inherited from Base

#code, #name

Instance Method Summary collapse

Methods inherited from Base

#==, all, assoc_collection, count, find_by, find_by_code, find_by_name, first, #hash, #initialize, #inspect, last, method_missing, reset_cache, respond_to_missing?, #to_s

Constructor Details

This class inherits a constructor from Pilipinas::Base

Instance Method Details

#barangaysArray<Barangay>

Returns the barangays belonging to this city or municipality.

Results are cached after the first call.

Returns:



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

def barangays
  Barangay.assoc_collection(code: code, dir: :cities)
end