<commit_before>//
//  Settings.swift
//  free-blur
//
//  Created by <NAME> on 6/30/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation
import UIKit

enum SettingsError : Error {
    case SettingValueOutsideAcceptedRange
}

class BlurSettings {
    private let numPassesKey = "numPasses"
    private let diameterKey = "diameter"
    private let userDefaults = UserDefaults.standard
    
    public var maxNumPasses : Int {
        return 5
    }

    public var minNumPasses : Int {
        return 1
    }

    public var numPassesDefault : Int {
        return 2
    }
    
    public var maxDiameter : Int {
        return 13
    }

    public var minDiameter : Int {
        return 2
    }

    public var diameterDefault : Int {
        return 3
    }
    
    func setDefaults() throws {
        if self.userDefaults.object(forKey: self.numPassesKey) == nil {
            try self.setNumPasses(numPasses: self.numPassesDefault)
        }

        if self.userDefaults.object(forKey: self.diameterKey) == nil {
            try self.setDiameter(diameter: self.diameterDefault)
        }
    }
    
    func getNumPasses() -> Int {
        let numPasses = userDefaults.integer(forKey: self.numPassesKey)
        if numPasses >= self.minNumPasses && numPasses <= self.maxNumPasses {
            return numPasses<commit_msg>Fixed error with saving diameter size.<commit_after>//
//  Settings.swift
//  free-blur
//
//  Created by <NAME> on 6/30/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation
import UIKit

enum SettingsError : Error {
    case SettingValueOutsideAcceptedRange
}

class BlurSettings {
    private let numPassesKey = "numPasses"
    private let diameterKey = "diameter"
    private let userDefaults = UserDefaults.standard
    
    public var maxNumPasses : Int {
        return 5
    }

    public var minNumPasses : Int {
        return 1
    }

    public var numPassesDefault : Int {
        return 2
    }
    
    public var maxDiameter : Int {
        return 15
    }

    public var minDiameter : Int {
        return 2
    }

    public var diameterDefault : Int {
        return 3
    }
    
    func setDefaults() throws {
        if self.userDefaults.object(forKey: self.numPassesKey) == nil {
            try self.setNumPasses(numPasses: self.numPassesDefault)
        }

        if self.userDefaults.object(forKey: self.diameterKey) == nil {
            try self.setDiameter(diameter: self.diameterDefault)
        }
    }
    
    func getNumPasses() -> Int {
        let numPasses = userDefaults.integer(forKey: self.numPassesKey)
        if numPasses >= self.minNumPasses && numPasses <= self.maxNumPasses {
            return numPasses
{'fraction_non_alphanumeric': 0.08342521131936788, 'fraction_numerical': 0.011760382212421904, 'mean_word_length': 2.1614401858304295, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '7193124', 'n_tokens_mistral': 876, 'n_tokens_neox': 805, 'n_words': 214}