Class: Isaca::Model::Countries

Inherits:
Object
  • Object
show all
Defined in:
lib/isaca/models/countries.rb

Overview

Class that is used as an object representation of the response from Request::Countries and Request::ExplicitCountries.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(countries) ⇒ Countries

Returns a new instance of Countries.

Parameters:

  • countries (Array<Hash>)

    Countries to create the object with.

Options Hash (countries):

  • :CODE (String)

    Required

  • :DESCRIPTION (String)

    Required



12
13
14
# File 'lib/isaca/models/countries.rb', line 12

def initialize(countries)
  @countries = countries.map { |c| Country.new(c[:CODE], c[:DESCRIPTION]) }
end

Instance Attribute Details

#countriesArray

Returns A list of countries that ISACA recognizes.

Returns:

  • (Array)

    A list of countries that ISACA recognizes.



6
7
8
# File 'lib/isaca/models/countries.rb', line 6

def countries
  @countries
end

Instance Method Details

#includes_country?(value) ⇒ Boolean

Method used to see if the a country exists. Searches across both country code and country description. Case insensitive.

Parameters:

  • value (String)

    The value to be searched.

Returns:

  • (Boolean)

    Whether or not the country is included.



21
22
23
24
# File 'lib/isaca/models/countries.rb', line 21

def includes_country?(value)
  @countries.each { |country| return true if country_matches?(country, value) }
  false
end