Created
August 7, 2015 20:06
-
-
Save chrisschreiner/71bf1fcc8ce572a4268d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public typealias GistID = Int | |
public typealias Result = Int | |
public typealias ConfigDict = [String:String] | |
public class GistWriter { // when you create the instance it will be invalid | |
private var activeGist: GistID? | |
public func configure(configuration:ConfigDict) { | |
//setup and whatnot | |
} | |
//return nil if the activeGist was not set beforehand | |
public func updateGist(text:String) -> NSURL? { | |
//createGist and setActiveGist if new | |
return NSURL(string:"") //return url | |
} | |
public func reset() {} //start a new gist on next update | |
private func createGist() -> GistID { | |
return 1 //arbitrary id | |
} | |
//whatever support functions you need | |
private func setActiveGist(id: GistID) { | |
activeGist = id | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage, so far:
instantiate the GistWriterThing
call updateGist(text) on the instance
call it several times will update the same gist
until you call reset
call updateGist(text) will create a new gist
call it several times will update the same gist
until you call reset
ad infinitum