Created
January 23, 2010 21:36
-
-
Save kevintyll/284812 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
class Pastie | |
PastieError = Class.new(StandardError) | |
ServiceNotAvailable = Class.new(PastieError) | |
LanguageNotSupported = Class.new(PastieError) | |
InvalidScope = Class.new(PastieError) | |
SCOPE = %w{ public private } | |
LANGUAGE = %w{java ruby cplusplus} | |
the document to be posted to pastie.org | |
attr_accessor :document, :scope, :src_type | |
# Initializes a Pastie object | |
# | |
# Required Arguments | |
# scope : Valid values are :public and :private | |
# language : The language of the source | |
# | |
# Return value: A Pastie object | |
# Possible Errors: | |
# LanguageNotSupported :: when an invalid language is supplied | |
# InvalidScope :: when an invalid scope is supplied | |
def initialize(scope, language) | |
@scope, @language = scope, language | |
valid_raise | |
self | |
end | |
# Returns a pastie document given an identefier from Pastie.paste | |
# Required Arguments | |
# identifier : The unique identifier | |
# | |
# Return value: A Pastie object | |
# Possible Errors: | |
# InvalidArgument :: when an invalid identifier is supplied | |
def self.copy(identifier) | |
end | |
# Pastes content to pastie.org and returns a unique identifier | |
# | |
# Return value: A unique identifier | |
# Possible Errors: | |
# DocumentNotSpecified :: when document is not set | |
# ServiceNotAvailable :: when pastie.org is down or unresponsive | |
def paste | |
#send to pastie.org | |
end | |
private | |
def valid_raise | |
return LanguageNotSupported unless LANGUAGE.include?(@language) | |
return InvalidScope unless SCOPE.include?(@scope) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment