Friday, 27 September 2013

Change the process of an code dependent on an variable

Change the process of an code dependent on an variable

Im trying to change the process of an code dependent on an variable req
how you can see here:
@res = @conn.post do |request| if req == 'post'
@res = @conn.get do |request| if req == 'get'
The problem is that this seems to raise an error:
stack.rb:89: syntax error, unexpected end-of-input, expecting keyword_end
user2.send_csr
My question is, what do i have to change to avoid this problem? If you
need more information about my code:
def send(req,ww,text1=nil,text2=nil)
@conn = Faraday.new 'https://zombo.de/rest', :ssl => {:verify => false}
@conn.basic_auth(@username,@password)
@res = @conn.post do |request| if req == 'post'
@res = @conn.get do |request| if req == 'get'
request.url ww
request.headers['Content-Type'] = text1 unless text1 == nil
request.body = text2 unless text2 == nil
end
puts @res.body
end
def send_csr
send('post','csr','text/plain',"#{File.read(@csr[0..-5])}")
end
user2.send_csr

No comments:

Post a Comment