Skip to content

Instantly share code, notes, and snippets.

@chrisschreiner
Created August 7, 2015 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisschreiner/71bf1fcc8ce572a4268d to your computer and use it in GitHub Desktop.
Save chrisschreiner/71bf1fcc8ce572a4268d to your computer and use it in GitHub Desktop.
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
}
}
@chrisschreiner
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment