Skip to content

Commit

Permalink
Added CustomStringConvertible conformance to Temperature struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaren Hamblin committed Apr 12, 2018
1 parent 06f5244 commit 162f119
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Source/Classes/TeslaAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import ObjectMapper

///
public protocol TeslaAPIDelegate: class {

///
Expand All @@ -21,12 +22,9 @@ public protocol TeslaAPIDelegate: class {
func teslaApi(_ teslaAPI: TeslaAPI, didSend command: TKCommand, data: TKCommandResponse?)
}


///
open class TeslaAPI {




// MARK: - Static Properties

///
Expand All @@ -44,6 +42,8 @@ open class TeslaAPI {
/// Base owner API URL with api version
public static let apiBaseURL: URL = baseURL.appendingPathComponent("api/\(TeslaAPI.apiVersion)")

// MARK: - Instance

/// Tesla API owner api client id
public let ownerApiClientId: String

Expand Down
8 changes: 7 additions & 1 deletion Source/Structures/Temperature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

/// An object representing a temperature unit
public struct Temperature {
public struct Temperature: CustomStringConvertible {

///
public static let Degree: String = "°"
Expand Down Expand Up @@ -55,7 +55,13 @@ public struct Temperature {
///
public var localizedFahrenheit: String { return String(format: "%.f", self.fahrenheit) + Temperature.Degree }

///
public func format(isFahrenheit: Bool) -> String {
return isFahrenheit ? self.localizedFahrenheit : self.localizedCelsius
}

///
public var description: String {
return self.localizedCelsius + " " + localizedFahrenheit
}
}

0 comments on commit 162f119

Please sign in to comment.