Git Product home page Git Product logo

rrbrazilianstate's Introduction

RRBrazilianState

Enum containing Brazilian states and cities.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To install CocoaPods, use the command below:

$ sudo gem install cocoapods

After install CocoaPods, specify this pod in your Podfile:

pod 'RRBrazilianState', '~> 1.0'

Then, run the command below:

$ pod install

Usage

After install this pod, you just need to import module in the file you are working on

import RRBrazilianState

Creating a reference for a specific state

let saoPaulo = RRBrazilianState.saoPaulo

You can also create a reference for a state from its abbreviation. See example below:

print(RRBrazilianState(abbreviation: "sp"))
// Prints "Optional(RRBrazilianState.RRBrazilianState.saoPaulo)"

print(RRBrazilianState(abbreviation: "rN"))
// Prints "Optional(RRBrazilianState.RRBrazilianState.rioGrandeDoNorte)"

print(RRBrazilianState(abbreviation: "Pi"))
// Prints "Optional(RRBrazilianState.RRBrazilianState.piaui)"

print(RRBrazilianState(abbreviation: "XY"))
// Prints "nil"

print(RRBrazilianState(abbreviation: "SP") == RRBrazilianState.saoPaulo)
// Prints "true"

As you could see, the abbreviation may be both uppercased and lowercased, but must be valid

Retriving state abbreviation

print(saoPaulo.rawValue)
// Prints "SP"

Retriving state name

print(saoPaulo.name)
// Prints "São Paulo"

Retriving state cities

print(saoPaulo.cities)
// Prints "["São Paulo", "Adamantina", "Adolfo", "Aguaí", "Águas da Prata", "Águas de Lindóia", ..."

Cities array is ordered alphabetically, but the first position is always reserved for the capital.

License

RRBrazilianState is released under the MIT license.

rrbrazilianstate's People

Contributors

rafaelrsilva avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.