Skip to content

Commit

Permalink
Add capitalize pokemon name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frog-Frog committed Dec 19, 2020
1 parent fa219cf commit b138c3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Domain/Model/PokemonDetail/PokemonDetailModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct PokemonDetailModel {

init(_ response: PokemonDetailResponse) {
self.number = response.id
self.name = response.name
self.name = response.name.capitalizingFirstLetter()
self.imageUrl = PokemonImageURLGenerator.generateImageURL(from: response.id)
self.typeHex = response.types.sorted { $0.slot < $1.slot }.compactMap { PokemonType($0) }.first?.hex ?? ""
self.information = Information(response)
Expand Down
2 changes: 1 addition & 1 deletion Domain/Model/PokemonList/PokemonListModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension PokemonListModel {
extension PokemonListModel.Pokemon {

init(_ pokemon: PokemonListResponse.Result) {
self.name = pokemon.name
self.name = pokemon.name.capitalizingFirstLetter()
self.number = PokemonNumberGenerator.generate(from: pokemon.url)
self.imageUrl = PokemonImageURLGenerator.generateThumbnailURL(from: self.number)
}
Expand Down
15 changes: 15 additions & 0 deletions Domain/Utility/Extensions/String+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// String+.swift
// Domain
//
// Created by Tomosuke Okada on 2020/12/19.
//

import Foundation

extension String {

func capitalizingFirstLetter() -> String {
return "\(self.prefix(1).uppercased())\(self.lowercased().dropFirst())"
}
}

0 comments on commit b138c3c

Please sign in to comment.