From c05be5cc119bca17fd4554b4f1a3192ecc550ca0 Mon Sep 17 00:00:00 2001 From: Haik Aslanyan Date: Wed, 19 Feb 2020 18:26:55 +0400 Subject: [PATCH] added RCBit --- Sources/Internal/RCBit.swift | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Sources/Internal/RCBit.swift diff --git a/Sources/Internal/RCBit.swift b/Sources/Internal/RCBit.swift new file mode 100644 index 0000000..46201ec --- /dev/null +++ b/Sources/Internal/RCBit.swift @@ -0,0 +1,44 @@ +// MIT License + +// Copyright (c) 2020 Haik Aslanyan + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +import Foundation + +enum RCBit: Int, CustomDebugStringConvertible { + + case zero + case one + + init?(_ character: Character) { + switch character { + case "0": + self = .zero + case "1": + self = .one + default: + return nil + } + } + + var debugDescription: String { + String(rawValue) + } +}