OSDN Git Service

処理を関数として吐き出し
authormasakih <masakih@users.sourceforge.jp>
Sat, 16 Dec 2017 14:04:21 +0000 (23:04 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sat, 16 Dec 2017 14:04:21 +0000 (23:04 +0900)
KCD/CombinedCommand.swift

index 2acb14a..48f9b0f 100644 (file)
@@ -34,15 +34,7 @@ final class CombinedCommand: JSONCommand {
         
         if api.endpoint == .port {
             
-            if let t = data["api_combined_flag"].int {
-                
-                CombineType(rawValue: t).map(postNotification(withType:))
-                
-            } else {
-                
-                postNotification(withType: .cancel)
-            }
-            
+            handlePort()
             return
         }
         
@@ -52,6 +44,18 @@ final class CombinedCommand: JSONCommand {
             .map(postNotification(withType:))
     }
     
+    private func handlePort() {
+        
+        if let t = data["api_combined_flag"].int {
+            
+            CombineType(rawValue: t).map(postNotification(withType:))
+            
+        } else {
+            
+            postNotification(withType: .cancel)
+        }
+    }
+    
     private func postNotification(withType type: CombineType) {
         
         let userInfo = [CombinedCommand.userInfoKey: type]