<commit_before>//  Copyright © 2016 <NAME>. All rights reserved.

import UIKit

final class WeatherViewController: UIViewController {

  @IBOutlet private weak var locationLabel: UILabel!
  @IBOutlet private weak var weatherInformationLabel: UILabel!
  @IBOutlet private weak var activityIndicator: UIActivityIndicatorView!
  @IBOutlet private var weatherView: WeatherView!

}

final class WeatherView: UIView {

  enum Theme {
    case blistering
    case hot
    case neutral
    case cold
  }

  override static var layerClass: AnyClass { return CAGradientLayer.self }

}

struct WeatherViewModel {

  private let data: Weather

  init(with data: Weather) {
    self.data = data
  }

  var location: City.Name { return data.city.name }

  var information: String { return String(format: "Current: %.1fºC", data.current) }

  var theme: WeatherView.Theme! {
    switch data.current {
    case let x where x >= 35.0: return .blistering
    case 25.0 ..< 35.0: return .hot
    case 18.0 ..< 25.0: return .neutral
    case let x where x < 18.0: return .cold
    default: return nil // This case should not be reached.
    }
  }

}

fileprivate extension WeatherView.Theme {
  var gradientColors: (top: UIColor, bottom: UIColor) {
    switch self {
    case .blistering:
      return (.init(rgb: (254, 229, 207)), .init(rgb: (253, 191, 132)))
    case .hot:
      return (.init(rgb: (254, 212, 171)), .init(rgb: (255, 240, 233)))
    case .neutral:
      return (.init(rgb: (226, 232, 254)), .init(rgb: (255, 249, 255)))
    case .cold:
      return (.init(rgb: (253, 194, 164)), .init(rgb: (226, 232, 254)))
    }
  }
}

fileprivate extension UIColor {

  convenience init(rgb: (Int, Int, Int), alpha: CGFloat = 1.0) {
    let red: CGFloat = CGFloat(rgb.0) / 255.0
    let green: CGFloat = CGFloat(rgb.1) / 255.0
    let blue: CGFloat = CGFloat(rgb.2) / 255.0

    self.init(red: red, green: green, blue: blue, alpha: alpha)
  }

}<commit_msg>Move extension functionality back into the type declaration<commit_after>//  Copyright © 2016 <NAME>. All rights reserved.

import UIKit

final class WeatherViewController: UIViewController {

  @IBOutlet private weak var locationLabel: UILabel!
  @IBOutlet private weak var weatherInformationLabel: UILabel!
  @IBOutlet private weak var activityIndicator: UIActivityIndicatorView!
  @IBOutlet private var weatherView: WeatherView!

}

final class WeatherView: UIView {

  enum Theme {
    case blistering
    case hot
    case neutral
    case cold

    fileprivate var gradientColors: (top: UIColor, bottom: UIColor) {
      switch self {
      case .blistering:
        return (.init(rgb: (254, 229, 207)), .init(rgb: (253, 191, 132)))
      case .hot:
        return (.init(rgb: (254, 212, 171)), .init(rgb: (255, 240, 233)))
      case .neutral:
        return (.init(rgb: (226, 232, 254)), .init(rgb: (255, 249, 255)))
      case .cold:
        return (.init(rgb: (255, 249, 255)), .init(rgb: (226, 232, 254)))
      }
    }
  }

  override static var layerClass: AnyClass { return CAGradientLayer.self }

}

struct WeatherViewModel {

  private let data: Weather

  init(with data: Weather) {
    self.data = data
  }

  var location: City.Name { return data.city.name }

  var information: String { return String(format: "Current: %.1fºC", data.current) }

  var theme: WeatherView.Theme! {
    switch data.current {
    case let x where x >= 35.0: return .blistering
    case 25.0 ..< 35.0: return .hot
    case 18.0 ..< 25.0: return .neutral
    case let x where x < 18.0: return .cold
    default: return nil // This case should not be reached.
    }
  }

}

fileprivate extension UIColor {

  convenience init(rgb: (Int, Int, Int), alpha: CGFloat = 1.0) {
    let red: CGFloat = CGFloat(rgb.0) / 255.0
    let green: CGFloat = CGFloat(rgb.1) / 255.0
    let blue: CGFloat = CGFloat(rgb.2) / 255.0

    self.init(red: red, green: green, blue: blue, alpha: alpha)
  }

}
{'fraction_non_alphanumeric': 0.12213156552779195, 'fraction_numerical': 0.05711371749107598, 'mean_word_length': 3.007150153217569, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5893682', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1290, 'n_words': 427}