samedi 21 octobre 2017

how to create GUI in ruby based on the code given?

This is the simple code I've written in ruby that will access to a rest server via HTTP methods.

class Rest_client

def get_method (host, path)
require 'net/http'
uri = URI.parse("#{host}")
http=Net::HTTP.new(uri.host,uri.port)
request = Net::HTTP::Get.new("#{path}")
reply=http.request(request)
puts "#{reply.code} #{reply.message}"
reply.header.each_header {|key,value| puts "#{key} = #{value}" } 
puts "#{reply.body}"

end

end
ARGV[2] == 'GET'
rc=Rest_client.new
rc.get_method(ARGV[0],ARGV[1])

How to write above mentioned code in GUI format based on this image ?I'm totally new in ruby and GUI, please guide me on how to do this.

Besides that, One of the criteria is the get button command proc should initialize these 4 things

  • connect to host using Rest_client
  • object get the method using Rest_client
  • Get the response using Rest_client
  • Update the label and text fields

Aucun commentaire:

Enregistrer un commentaire