<commit_before>//
//  BatteryStatus.swift
//  RileyLink
//
//  Created by <NAME> on 7/28/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public struct BatteryStatus {
    let percent: Int?
    let voltage: Double?
    let status: String?
    
    public init(percent: Int? = nil, voltage: Double? = nil, status: String? = nil) {
        self.percent = percent
        self.voltage = voltage
        self.status = status
    }
    
    public var dictionaryRepresentation: [String: AnyObject] {
        var rval = [String: AnyObject]()
        
        if let percent = percent {
            rval["percent"] = percent
        }
        if let voltage = voltage {
            rval["voltage"] = voltage
        }

        if let status = status {
            rval["status"] = status
        }
        
        return rval
    }
}<commit_msg>Adding BatteryIndicator to enumerate values for the nightscout battery.status field<commit_after>//
//  BatteryStatus.swift
//  RileyLink
//
//  Created by <NAME> on 7/28/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public enum BatteryIndicator: String {
    case Absolute = "absolute"
    case Percentage = "percentage"
}

public struct BatteryStatus {
    let percent: Int?
    let voltage: Double?
    let indicator: BatteryIndicator?
    
    public init(percent: Int? = nil, voltage: Double? = nil, indicator: BatteryIndicator? = nil) {
        self.percent = percent
        self.voltage = voltage
        self.indicator = indicator
    }
    
    public var dictionaryRepresentation: [String: AnyObject] {
        var rval = [String: AnyObject]()
        
        if let percent = percent {
            rval["percent"] = percent
        }
        if let voltage = voltage {
            rval["voltage"] = voltage
        }

        if let indicator = indicator {
            rval["status"] = indicator.rawValue
        }
        
        return rval
    }
}
{'fraction_non_alphanumeric': 0.10040774719673802, 'fraction_numerical': 0.009174311926605505, 'mean_word_length': 1.9607843137254901, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7553041', 'n_tokens_mistral': 570, 'n_tokens_neox': 539, 'n_words': 167}