Module: Qs
- Defined in:
- lib/function/sfunction.rb
Instance Method Summary collapse
-
#cutEndline(text) ⇒ Object
0.0.8.
- #decoder(n) ⇒ Object
- #getDir(file, type = 1) ⇒ Object
- #getFile(name) ⇒ Object
- #getPathExe(default_dir) ⇒ Object
-
#getRandomString(n, i) ⇒ Object
i=1: 0-9,a-z,A-Z
i=2: -_
i=3: a-z,A-Z
i=4: 0-9
i=41: 0-9
i=5: @domain
i=10: Ho va Ten
. - #randfromto(a, b) ⇒ Object
- #readExcel(dir, sheet = 1) ⇒ Object
- #saveExcel ⇒ Object
- #send_Mail_on_Gmail(nickname, pass, to, subject, content) ⇒ Object
Instance Method Details
#cutEndline(text) ⇒ Object
0.0.8
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/function/sfunction.rb', line 92 def cutEndline(text) #0.0.8 if RUBY_VERSION <= '1.8.6' then if text[text.length - 1] < 32 then return text[0,text.length - 1] else return text[0,text.length] end else if text[text.length - 1] < ' ' then return text[0,text.length - 1] else return text[0,text.length] end end end |
#decoder(n) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/function/sfunction.rb', line 2 def decoder(n) str = [" ","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";", "<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", "[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x", "y","z","{","|","}","~" ] for i in 32..126 if n == i then return "#{str[i-32]}" end end end |
#getDir(file, type = 1) ⇒ Object
135 136 137 138 139 140 |
# File 'lib/function/sfunction.rb', line 135 def getDir(file,type = 1) if type == 1 then return File.dirname(file).gsub('/', '\\') + "\\" else return File.dirname(file).gsub('/', '\\') end end |
#getFile(name) ⇒ Object
120 121 122 123 124 |
# File 'lib/function/sfunction.rb', line 120 def getFile(name) if File.exist?(name) then return true else return false end end |
#getPathExe(default_dir) ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'lib/function/sfunction.rb', line 126 def getPathExe(default_dir) if ENV['OCRA_EXECUTABLE'].nil? root_dir = File.dirname(default_dir).gsub('/', '\\') #0.0.7 else root_dir = File.(File.dirname(ENV['OCRA_EXECUTABLE'])).gsub('/', '\\') end return root_dir + "\\" end |
#getRandomString(n, i) ⇒ Object
i=1: 0-9,a-z,A-Z
i=2: -_
i=3: a-z,A-Z
i=4: 0-9
i=41: 0-9
i=5: @domain
i=10: Ho va Ten
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/function/sfunction.rb', line 20 def getRandomString(n,i) str = "" str1 = ["0","1","2","3","4","5","6","7","8","9", "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x", "y","z"] str2 = ["-","","_",""] str3 = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] str4 = ["0","1","2","3","4","5","6","7","8","9"] str41 = ["0","1","2","3","4","5","6","7","8","9","","","","","","","","","",""] str5 = ["@yahoo.com.vn","@gmail.com","@yahoo.com","@msn.com","@hotmail.com","@zing.vn","@google.com.vn","@dantri.com", "@vnexpress.net","@mail.com","@abc.com","@live.com"] strHo = ["Nguyen","Dinh","Dang","Huynh","Mai","Tran","Le","Hoang","Pham","Phan","Vu","Bui","Do","Ho","Ngo", "Duong","Ly","Vuong","Trinh","Truong","Dinh","Doan","Lam","Phung"] strTenDem = ["Thi","Hong","Van","","Duc","Thuy","Ngoc","Ly","Bac","Hien"] strTen = ["Trai","Xi","Truc","Tu","Bat","Thanh","Luong","Khuong","Quyen","Quang", "Hoang","Ky","Thai","Chinh","Trinh","Kien","Hao","Hung","Quynh","Phuong","Hoa","Hop","Dung","Thang","Van","Tu","Ninh","Vinh","Loc","Khanh","Thuy","Ha", "Hang","Lam","Hai","Vu","Na","Duyen","Minh","Tuan","Hien","Anh","An","Be","Binh","Canh"] if i == 1 then for i in 1..n str = "#{str}#{str1[rand(str1.length)]}" end return str elsif i == 2 then for i in 1..n str = "#{str}#{str2[rand(str2.length)]}" end return str elsif i == 3 then for i in 1..n str = "#{str}#{str3[rand(str3.length)]}" end return str elsif i == 4 then for i in 1..n str = "#{str}#{str4[rand(10)]}" end return str elsif i == 41 then for i in 1..n str = "#{str}#{str41[rand(str41.length)]}" end return str elsif i == 5 then for i in 1..n str = "#{str}#{str5[rand(str5.length)]}" end return str elsif i == 10 then str = "#{strHo[rand(strHo.length)]} #{strTenDem[rand(strTenDem.length)]} #{strTen[rand(strTen.length)]}" return str end end |
#randfromto(a, b) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/function/sfunction.rb', line 84 def randfromto(a,b) x = rand(b) while x < a do x = rand(b) end return x end |
#readExcel(dir, sheet = 1) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/function/sfunction.rb', line 106 def readExcel(dir,sheet=1) $excel = WIN32OLE.new("excel.application") $excel.visible = true $workbook = $excel.workbooks.open(dir) $ws=$workbook.worksheets(sheet) $workbook = $excel.ActiveWorkbook end |
#saveExcel ⇒ Object
114 115 116 117 118 |
# File 'lib/function/sfunction.rb', line 114 def saveExcel $workbook.Save $workbook.Close $excel.Quit end |
#send_Mail_on_Gmail(nickname, pass, to, subject, content) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/function/sfunction.rb', line 142 def send_Mail_on_Gmail(nickname,pass,to,subject,content) g = GmailSender.new(nickname, pass) g.send(:to => to, :subject => subject, :content => content, :content_type => 'text/html') end |