Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'mysql'
- #Getting the Current Wind
- html = "st141=238/9&st121=285/13&st161=294/6&st191=300/17&st181=305/11&st171=309/12&st131=336/19&DataTransfer=complete";
- test = html.split("st");
- finalSt = test[test.length-1].split("&");
- #The Update Method
- def updateProcess(info)
- hostname= "localhost"
- username= ""
- password= ""
- database= ""
- # Connect to MySQL and return a MySQL Object
- my = Mysql.new(hostname, username, password, database)
- # Increase the Percentage
- 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);
- st.execute()
- #Decreasing the Percentage
- 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);
- st.execute()
- st.close;
- end
- #Method the separate items
- def splitMethod(word)
- whole = word.split("=");
- windAndSpeed= whole[1].split("/");
- splitedInfo = [0,0,0];
- splitedInfo[0] = whole[0];
- splitedInfo[1] =windAndSpeed[0];
- splitedInfo[2] = windAndSpeed[1];
- updateProcess(splitedInfo);
- end
- #Splitting the Information
- for i in 1..test.length-2 do
- splitMethod(test[i].chomp)
- end
- splitMethod(finalSt[0]);
Add Comment
Please, Sign In to add comment