<commit_before>//
//  Advertisement.swift
//  MoBetterBluetooth
//
//  Created by <NAME> on 4/14/17.
//  Copyright © 2017 Verticon. All rights reserved.
//

import Foundation
import CoreBluetooth
import VerticonsToolbox

public struct Advertisement : CustomStringConvertible {
    public internal(set) var data: [String : Any]
    
    internal init(_ data: [String : Any]) {
        self.data = data
    }
    
    // TODO: Why is the manufacturer ID being skipped?
    public var manufacturerSpecificData: [String]? {
        get {
            if let manufacturerData = data[CBAdvertisementDataManufacturerDataKey] as? Data {
                let skipManufacturerId = manufacturerData.subdata(in: 2..<(manufacturerData.count - 2))
                return skipManufacturerId.asStringArray()
            }
            return nil
        }
    }
    
    public var isConnectable: Bool {
        return data[CBAdvertisementDataIsConnectable] as? Bool ?? false
    }
    
    public var description : String {
        var description = "<"
        
        if data.count > 0 {
            var firstEntry = true
            for entry in data {
                description += "\(firstEntry ? "" : ", ")\(describeEntry(entry))"
                firstEntry = false
            }
        }
        else {
            description += "no advertisement data"<commit_msg>Minor tweak to accommodate changes to Data extensions.<commit_after>//
//  Advertisement.swift
//  MoBetterBluetooth
//
//  Created by <NAME> on 4/14/17.
//  Copyright © 2017 Verticon. All rights reserved.
//

import Foundation
import CoreBluetooth
import VerticonsToolbox

public struct Advertisement : CustomStringConvertible {
    public internal(set) var data: [String : Any]
    
    internal init(_ data: [String : Any]) {
        self.data = data
    }
    
    // TODO: Why is the manufacturer ID being skipped?
    public var manufacturerSpecificData: [String]? {
        get {
            if let manufacturerData = data[CBAdvertisementDataManufacturerDataKey] as? Data {
                let skipManufacturerId = manufacturerData.subdata(in: 2..<(manufacturerData.count - 2))
                return skipManufacturerId.toStringArray()
            }
            return nil
        }
    }
    
    public var isConnectable: Bool {
        return data[CBAdvertisementDataIsConnectable] as? Bool ?? false
    }
    
    public var description : String {
        var description = "<"
        
        if data.count > 0 {
            var firstEntry = true
            for entry in data {
                description += "\(firstEntry ? "" : ", ")\(describeEntry(entry))"
                firstEntry = false
            }
        }
        else {
            description += "no advertisement data"
{'fraction_non_alphanumeric': 0.0896551724137931, 'fraction_numerical': 0.008711433756805808, 'mean_word_length': 1.9730312837108954, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2136311', 'n_tokens_mistral': 777, 'n_tokens_neox': 707, 'n_words': 208}