Class: APIBuilder::DSL

Inherits:
Object
  • Object
show all
Defined in:
bin/minecraftctlserver

Defined Under Namespace

Classes: OP

Instance Method Summary collapse

Constructor Details

#initialize(sinatra, path, &block) ⇒ DSL

Returns a new instance of DSL.



98
99
100
101
102
103
104
105
106
107
# File 'bin/minecraftctlserver', line 98

def initialize(sinatra, path, &block)
	@sinatra = sinatra
	@path = path

	@gets = []
	@posts = []
	@paths = []

	instance_eval(&block)
end

Instance Method Details

#dataObject



109
110
111
# File 'bin/minecraftctlserver', line 109

def data
	Struct.new(:gets, :posts, :paths).new(@gets, @posts, @paths)
end

#get(name, description, &block) ⇒ Object



113
114
115
# File 'bin/minecraftctlserver', line 113

def get(name, description, &block)
	@gets << OP.new(name, description, block)
end

#path(name, description, &block) ⇒ Object



121
122
123
# File 'bin/minecraftctlserver', line 121

def path(name, description, &block)
	@paths << APIBuilder.new(@sinatra, description, @path + '/' + name, &block)
end

#post(name, description, &block) ⇒ Object



117
118
119
# File 'bin/minecraftctlserver', line 117

def post(name, description, &block)
	@posts << OP.new(name, description, block)
end