Module: Mtbb::NetThings

Defined in:
lib/mtbb.rb

Instance Method Summary collapse

Instance Method Details

#delete_request(options = {}) ⇒ Object



281
282
283
284
285
286
# File 'lib/mtbb.rb', line 281

def delete_request(options = {})
  perform_request(
    Net::HTTP::Delete.new(options[:path] || '/'),
    options.fetch(:port)
  )
end

#get_request(options = {}) ⇒ Object



274
275
276
277
278
279
# File 'lib/mtbb.rb', line 274

def get_request(options = {})
  perform_request(
    Net::HTTP::Get.new(options[:path] || '/'),
    options.fetch(:port)
  )
end

#http(method_name, path, options = {}) ⇒ Object



262
263
264
265
# File 'lib/mtbb.rb', line 262

def http(method_name, path, options = {})
  options[:path] ||= path
  send("#{method_name.downcase}_request", options)
end

#post_request(options = {}) ⇒ Object



267
268
269
270
271
272
# File 'lib/mtbb.rb', line 267

def post_request(options = {})
  request = Net::HTTP::Post.new(options[:path] || '/')
  request.content_type = 'application/x-www-form-urlencoded'
  request.body = options.fetch(:body)
  perform_request(request, options.fetch(:port))
end