Guest User

Untitled

a guest
May 1st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. require 'rubygems'
  2.  
  3. require 'mysql'
  4.  
  5. #Getting the Current Wind
  6. html = "st141=238/9&st121=285/13&st161=294/6&st191=300/17&st181=305/11&st171=309/12&st131=336/19&DataTransfer=complete";
  7. test = html.split("st");
  8. finalSt = test[test.length-1].split("&");
  9.  
  10. #The Update Method
  11. def updateProcess(info)
  12.  
  13.  
  14. hostname= "localhost"
  15. username= ""
  16. password= ""
  17. database= ""
  18.  
  19.  
  20.  
  21. # Connect to MySQL and return a MySQL Object
  22.  
  23.  
  24.  
  25. my = Mysql.new(hostname, username, password, database)
  26. # Increase the Percentage
  27.  
  28.  
  29. st = my.prepare("update tblSwimmingAreas set bramPoss = bramPoss + 10 where " + info[1].to_s + " >= lowDegre AND " + info[1].to_s + " <= highDegre and bramPoss < 70 and stID = " + info[0].to_s);
  30.  
  31. st.execute()
  32.  
  33.  
  34. #Decreasing the Percentage
  35. st = my.prepare("update tblSwimmingAreas set bramPoss = bramPoss - 10 where " + ((info[1]+180).to_s) + " >= lowDegre AND " + ((info[1]+180).to_s) + " <= highDegre and bramPoss >= 10 and stID = " + info[0].to_s);
  36.  
  37. st.execute()
  38. st.close;
  39. end
  40.  
  41. #Method the separate items
  42. def splitMethod(word)
  43. whole = word.split("=");
  44. windAndSpeed= whole[1].split("/");
  45. splitedInfo = [0,0,0];
  46. splitedInfo[0] = whole[0];
  47. splitedInfo[1] =windAndSpeed[0];
  48. splitedInfo[2] = windAndSpeed[1];
  49. updateProcess(splitedInfo);
  50. end
  51.  
  52. #Splitting the Information
  53. for i in 1..test.length-2 do
  54. splitMethod(test[i].chomp)
  55. end
  56.  
  57. splitMethod(finalSt[0]);
Add Comment
Please, Sign In to add comment