Class: GovKit::CA::PostalCode::Strategy::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/gov_kit-ca/postal_code/strategy/base.rb

Overview

Abstract class for implementing postal code to electoral district strategies.

The following instance methods must be implemented in sub-classes:

  • electoral_districts!

The following class methods must be called in sub-classes:

  • http_method
  • path

Instance Method Summary collapse

Constructor Details

#initialize(postal_code) ⇒ Base

Creates a new postal code to electoral district strategy.

Parameters:

  • postal_code (String)

    a postal code



23
24
25
# File 'lib/gov_kit-ca/postal_code/strategy/base.rb', line 23

def initialize(postal_code)
  @postal_code = postal_code
end

Instance Method Details

#electoral_districtsArray<Fixnum>

Returns the electoral districts within a postal code.

Returns:

  • (Array<Fixnum>)

    the electoral districts within the postal code



29
30
31
# File 'lib/gov_kit-ca/postal_code/strategy/base.rb', line 29

def electoral_districts
  valid? && electoral_districts!.map(&:to_i).sort
end