Module: Utilities
- Defined in:
- lib/kuali-sakai-common-lib/utilities.rb
Overview
Provides useful helper methods for creating test data. For example, strings of random text, random date values formatted as needed, and other misc methods. Include in your test step class.
Instance Method Summary collapse
-
#current_hour ⇒ Object
Returns the value of the current hour as an Integer object, which eliminates the zero-padding for single-digit hours.
-
#current_month ⇒ Object
Returns an all-caps 3-char string equal to the current month.
-
#current_year ⇒ Object
Returns a 4-digit Integer object equal to the current year.
-
#get_filename(path_plus_name_string) ⇒ Object
Strips the file name away from the path information.
-
#in_15_minutes ⇒ Object
returns a hash object containing strings that will, for example, allow creation of an event starting 15 minutes in the future.
-
#last_hour ⇒ Object
Returns the value of the last hour as an Integer object, which eliminates the zero-padding for single-digit hours.
-
#last_month ⇒ Object
Returns an all-caps 3-char string equal to the prior month.
-
#last_year ⇒ Object
Returns a 4-digit Integer object, equal to last year.
-
#make_date(time_object, type = "cle") ⇒ Object
Takes a time object as the input (e.g., Time.now) and returns a string formatted in particular ways.
-
#next_hour ⇒ Object
Returns the value of the next hour as an Integer object, which eliminates the zero-padding for single-digit hours.
-
#next_month ⇒ Object
Returns an all-caps 3-char string equal to next month.
-
#next_year ⇒ Object
Returns a 4-digit Integer object equal to next year.
-
#on_page(page_class, &block) ⇒ Object
Creates a page object based on the class passed to it.
-
#random_alphanums(length = 10, s = "") ⇒ Object
A random string generator that uses only letters and numbers in the string.
-
#random_alphanums_plus(length = 10, s = "") ⇒ Object
A random string generator that uses all characters available on an American Qwerty keyboard.
-
#random_email(x = 62) ⇒ Object
Returns a string that is properly formatted like an email address.
-
#random_high_ascii(length = 10, s = "") ⇒ Object
A random string creator that draws from all printable ASCII and High ASCII characters from 33 to 256.
-
#random_letters(length = 10, s = "") ⇒ Object
A random string generator that uses only lower case letters.
-
#random_multiline(word_count = 2, line_count = 2, char_type = :alpha) ⇒ Object
Returns a block of text (of the specified type, see below) containing the specified number of “words” (each containing between 1 and 16 chars) randomly spread across the specified number of lines (note that the method does not allow the line count to be larger than the word count and will “fix” it if it is).
-
#random_nicelink(length = 10) ⇒ Object
A “friendlier” random string generator.
-
#random_string(length = 10, s = "") ⇒ Object
A random string creator that draws from all printable ASCII characters from 33 to 128.
-
#random_xss_string(number = 102) ⇒ Object
Picks at random from the list of XSS test strings, using the provided number as size of the list to choose from.
-
#tomorrow ⇒ Object
Returns an Integer object equal to tomorrow’s day of the month.
-
#yesterday ⇒ Object
Returns an Integer object equal to yesterday’s day of the month.
Instance Method Details
#current_hour ⇒ Object
Returns the value of the current hour as an Integer object, which eliminates the zero-padding for single-digit hours. 12-hour clock.
156 157 158 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 156 def current_hour Time.now.strftime("%I").to_i end |
#current_month ⇒ Object
Returns an all-caps 3-char string equal to the current month
184 185 186 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 184 def current_month Time.now.strftime("%^b") end |
#current_year ⇒ Object
Returns a 4-digit Integer object equal to the current year.
172 173 174 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 172 def current_year (Time.now).strftime("%Y").to_i end |
#get_filename(path_plus_name_string) ⇒ Object
Strips the file name away from the path information.
This way it’s not necessary to define variables for BOTH the file name and the file path + file name. Just define the path + name and then use this method to extract only the filename portion.
27 28 29 30 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 27 def get_filename(path_plus_name_string) path_plus_name_string =~ /(?<=\/).+/ return $~.to_s end |
#in_15_minutes ⇒ Object
returns a hash object containing strings that will, for example, allow creation of an event starting 15 minutes in the future. Hour and Day values are Integer objects, not strings, so that they will not be zero-padded. The :meridian string is lower-case.
249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 249 def in_15_minutes t = Time.now.utc+15*60 return { :month_str => t.strftime("%^b"), :month_int => t.strftime("%-m"), :day =>t.strftime("%d").to_i, :year =>t.strftime("%Y").to_i, :hour =>t.strftime("%I").to_i, :minute =>(t-t.sec-t.min%5*60).strftime("%M"), :meridian =>t.strftime("%P") } end |
#last_hour ⇒ Object
Returns the value of the last hour as an Integer object, which eliminates the zero-padding for single-digit hours. 12-hour clock.
150 151 152 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 150 def last_hour (Time.now - 3600).strftime("%I").to_i end |
#last_month ⇒ Object
Returns an all-caps 3-char string equal to the prior month
177 178 179 180 181 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 177 def last_month months = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"] index = months.index(current_month) return months[index-1] end |
#last_year ⇒ Object
Returns a 4-digit Integer object, equal to last year.
167 168 169 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 167 def last_year (Time.now - (3600*24*365)).strftime("%Y").to_i end |
#make_date(time_object, type = "cle") ⇒ Object
Takes a time object as the input (e.g., Time.now) and returns a string formatted in particular ways. When the specified “type” value is “cle” (or not specified), The returned string will look like this: “Jan 9, 2012 1:12 am” When “oae-message”: “2/8/2012 1:06 PM” Note the lack of zero-padding for the day of the month and the hour of the day. The hour value will be for a 12-hour clock.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 227 def make_date(time_object, type="cle") case(type) when "cle" month = time_object.strftime("%b ") day = time_object.strftime("%d").to_i year = time_object.strftime(", %Y ") mins = time_object.strftime(":%M %P") hour = time_object.strftime("%l").to_i return month + day.to_s + year + hour.to_s + mins when "oae-message" date = time_object.strftime("%-m/%-d/%Y ") hour = time_object.strftime("%l").to_i mins = time_object.strftime(":%M %p") return date + hour.to_s + mins end end |
#next_hour ⇒ Object
Returns the value of the next hour as an Integer object, which eliminates the zero-padding for single-digit hours. 12-hour clock.
162 163 164 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 162 def next_hour (Time.now + 3600).strftime("%I").to_i end |
#next_month ⇒ Object
Returns an all-caps 3-char string equal to next month
189 190 191 192 193 194 195 196 197 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 189 def next_month months = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"] index = months.index(current_month) if index < 12 return months[index+1] else return months[0] end end |
#next_year ⇒ Object
Returns a 4-digit Integer object equal to next year.
200 201 202 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 200 def next_year (Time.now + (3600*24*365)).strftime("%Y").to_i end |
#on_page(page_class, &block) ⇒ Object
Creates a page object based on the class passed to it.
15 16 17 18 19 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 15 def on_page(page_class, &block) @current_page = page_class.new(@browser) block.call @current_page if block @current_page end |
#random_alphanums(length = 10, s = "") ⇒ Object
A random string generator that uses only letters and numbers in the string. Default length is 10 characters.
75 76 77 78 79 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 75 def random_alphanums(length=10, s="") chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789' length.times { s << chars[rand(chars.size)] } s.to_s end |
#random_alphanums_plus(length = 10, s = "") ⇒ Object
A random string generator that uses all characters available on an American Qwerty keyboard.
68 69 70 71 72 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 68 def random_alphanums_plus(length=10, s="") chars = %w{ a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ` ~ ! @ # $% ^ & * ( ) _ + - = { } [ ] \ : " ; ' < > ? , . / } length.times { s << chars[rand(chars.size)] } s.to_s end |
#random_email(x = 62) ⇒ Object
Returns a string that is properly formatted like an email address. The string returned defaults to 268 characters long. Including a number between 1 and 62 will shrink this string by 62 minus the specified value.
60 61 62 63 64 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 60 def random_email(x=62) x > 62 ? x=62 : x=x chars = %w{a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % & ' * + - / = ? ^ _ ` { | } ~} random_alphanums(1) + (0...x).map { chars[rand(chars.size)]}.join + random_alphanums(1) + "@" + random_alphanums(60) + ".com" end |
#random_high_ascii(length = 10, s = "") ⇒ Object
A random string creator that draws from all printable ASCII and High ASCII characters from 33 to 256. Default length is 10 characters.
42 43 44 45 46 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 42 def random_high_ascii(length=10, s="") length.enum_for(:times).inject(s) do |result, index| s << rand(223) + 33 end end |
#random_letters(length = 10, s = "") ⇒ Object
A random string generator that uses only lower case letters.
82 83 84 85 86 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 82 def random_letters(length=10, s="") chars = 'abcdefghjkmnpqrstuvwxyz' length.times { s << chars[rand(chars.size)] } s.to_s end |
#random_multiline(word_count = 2, line_count = 2, char_type = :alpha) ⇒ Object
Returns a block of text (of the specified type, see below) containing the specified number of “words” (each containing between 1 and 16 chars) randomly spread across the specified number of lines (note that the method does not allow the line count to be larger than the word count and will “fix” it if it is).
If no arguments are provided, the method will return two alphanumeric “words” on two lines.
The last argument the method takes will determine the character content of the string, viz.:
:alpha => Alphanumeric -> uses the random_alphanums method :string => uses the random_string method, so chars 33 through 128 will be included :ascii => All ASCII chars from 33 to 256 are fair game -> uses random_high_ascii
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 103 def random_multiline(word_count=2, line_count=2, char_type=:alpha) char_methods = {:alpha=>"random_alphanums(rand(16)+1)", :string=>"random_string(rand(16)+1)", :ascii=>"random_high_ascii(rand(16)+1)"} if line_count > word_count line_count = word_count - 1 end words = [] non_words = [] word_count.times { words << eval(char_methods[char_type]) } # creating the words, adding to the array (line_count - 1).times { non_words << "\n" } # adding the number of line feeds unless word_count==line_count (word_count - line_count - 1).times { non_words << " " } # adding the right number of spaces end non_words.shuffle! # Have to shuffle the line feeds around! array = words.zip(non_words) array.flatten! return array.join("") end |
#random_nicelink(length = 10) ⇒ Object
A “friendlier” random string generator. No characters need to be escaped for valid URLs. Uses no Reserved or “Unsafe” characters. Also excludes the comma, the @ sign and the plus sign. Default length is 10 characters.
51 52 53 54 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 51 def random_nicelink(length=10) chars = %w{a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 _ - .} (0...length).map { chars[rand(chars.size)]}.join end |
#random_string(length = 10, s = "") ⇒ Object
A random string creator that draws from all printable ASCII characters from 33 to 128. Default length is 10 characters.
34 35 36 37 38 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 34 def random_string(length=10, s="") length.enum_for(:times).inject(s) do |result, index| s << rand(93) + 33 end end |
#random_xss_string(number = 102) ⇒ Object
Picks at random from the list of XSS test strings, using the provided number as size of the list to choose from. It will randomly pre-pend the string with HTML closing tags.
The strings are organized by length, with the shorter ones first. There are 102 strings.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 127 def random_xss_string(number=102) if number > 102 number = 102 end xss = ["<PLAINTEXT>", "\\\";alert('XSS');//", "'';!--\"<XSS>=&{()}", "<IMG SRC=\"mocha:alert('XSS')\">", "<BODY ONLOAD=alert('XSS')>", "<BODY ONLOAD =alert('XSS')>", "<BR SIZE=\"&{alert('XSS')}\">", "¼script¾alert(¢XSS¢)¼/script¾", "<IMG SRC=\"livescript:alert('XSS')\">", "<SCRIPT SRC=//ha.ckers.org/.j>", "<IMG SRC=javascript:alert('XSS')>", "<IMG SRC=JaVaScRiPt:alert('XSS')>", "<<SCRIPT>alert(\"XSS\");//<</SCRIPT>", "<IMG SRC=\"javascript:alert('XSS')\"", "<IMG SRC='vbscript:msgbox(\"XSS\")'>", "<A HREF=\"http://1113982867/\">XSS</A>", "<IMG SRC=\"javascript:alert('XSS');\">", "<IMG SRC=\"jav\tascript:alert('XSS');\">", "<XSS STYLE=\"behavior: url(xss.htc);\">", "</TITLE><SCRIPT>alert(\"XSS\");</SCRIPT>", "<IMG DYNSRC=\"javascript:alert('XSS')\">", "<A HREF=\"http://66.102.7.147/\">XSS</A>", "<IMG LOWSRC=\"javascript:alert('XSS')\">", "<BGSOUND SRC=\"javascript:alert('XSS');\">", "<BASE HREF=\"javascript:alert('XSS');//\">", "<IMG \"\"\"><SCRIPT>alert(\"XSS\")</SCRIPT>\">", "<SCRIPT>a=/XSS/ alert(a.source)</SCRIPT>", "<IMG SRC=\"jav
ascript:alert('XSS');\">", "<IMG SRC=\"jav
ascript:alert('XSS');\">", "<XSS STYLE=\"xss:expression(alert('XSS'))\">", "<IMG SRC=\"jav	ascript:alert('XSS');\">", "<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>", "<IMG SRC=\"  javascript:alert('XSS');\">", "<IMG SRC=javascript:alert("XSS")>", "<BODY BACKGROUND=\"javascript:alert('XSS')\">", "<TABLE BACKGROUND=\"javascript:alert('XSS')\">", "<DIV STYLE=\"width: expression(alert('XSS'));\">", "<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">", "<iframe src=http://ha.ckers.org/scriptlet.html <", "<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>", "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>", "<A HREF=\"http://0x42.0x0000066.0x7.0x93/\">XSS</A>", "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">", "<A HREF=\"http://0102.0146.0007.00000223/\">XSS</A>", "<IMG SRC=`javascript:alert(\"RSnake says, 'XSS'\")`>", "<SCRIPT/SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<SCRIPT SRC=\"http://ha.ckers.org/xss.jpg\"></SCRIPT>", "<STYLE TYPE=\"text/javascript\">alert('XSS');</STYLE>", "<BODY onload!\#$%&()*~+-_.,:;?@[/|\\]^`=alert(\"XSS\")>", "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">", "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>", "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>", "<SCRIPT/XSS SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<? echo('<SCR)'; echo('IPT>alert(\"XSS\")</SCRIPT>'); ?>", "<SCRIPT =\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">", "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>", "<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>", "<SCRIPT \"a='>'\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">", "<SCRIPT a=\">'>\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>", "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">", "perl -e 'print \"<SCR\\0IPT>alert(\\\"XSS\\\")</SCR\\0IPT>\";' > out", "<IMG SRC = \" j a v a s c r i p t : a l e r t ( ' X S S ' ) \" >", "Redirect 302 /a.jpg http://www.rsmart.com/admin.asp&deleteuser", "perl -e 'print \"<IMG SRC=java\\0script:alert(\\\"XSS\\\")>\";' > out", "<!--[if gte IE 4]> <SCRIPT>alert('XSS');</SCRIPT> <![endif]-->", "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">", "<A HREF=\"http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D\">XSS</A>", "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">", "a=\"get\"; b=\"URL(\\\"\"; c=\"javascript:\"; d=\"alert('XSS');\\\")\"; eval(a+b+c+d);", "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>", "<EMBED SRC=\"http://ha.ckers.org/xss.swf\" AllowScriptAccess=\"always\"></EMBED>", "<STYLE type=\"text/css\">BODY{background:url(\"javascript:alert('XSS')\")}</STYLE>", "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>XSS", "<META HTTP-EQUIV=\"Link\" Content=\"<http://ha.ckers.org/xss.css>; REL=stylesheet\">", "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">", "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>", "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>", "<STYLE>.XSS{background-image:url(\"javascript:alert('XSS')\");}</STYLE><A CLASS=XSS></A>", "<XML SRC=\"xsstest.xml\" ID=I></XML> <SPAN DATASRC=#I DATAFLD=C DATAFORMATAS=HTML></SPAN>", "<META HTTP-EQUIV=\"Set-Cookie\" Content=\"USERID=<SCRIPT>alert('XSS')</SCRIPT>\">", "exp/*<A STYLE='no\\xss:noxss(\"*//*\"); xss:ex/*XSS*//*/*/pression(alert(\"XSS\"))'>", "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">", "<!--#exec cmd=\"/bin/echo '<SCR'\"--><!--#exec cmd=\"/bin/echo 'IPT SRC=http://ha.ckers.org/xss.js></SCRIPT>'\"-->", "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>", "<HTML xmlns:xss> <?import namespace=\"xss\" implementation=\"http://ha.ckers.org/xss.htc\"> <xss:xss>XSS</xss:xss> </HTML>", "<IMG SRC=javascript:alert('XSS')>", "<HEAD><META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=UTF-7\"> </HEAD>+ADw-SCRIPT+AD4-alert('XSS');+ADw-/SCRIPT+AD4-", "<IMG SRC=javascript:alert('XSS')>", "<XML ID=I><X><C><![CDATA[<IMG SRC=\"javas]]><![CDATA[cript:alert('XSS');\">]]> </C></X></xml><SPAN DATASRC=#I DATAFLD=C DATAFORMATAS=HTML></SPAN>", "<XML ID=\"xss\"><I><B><IMG SRC=\"javas<!-- -->cript:alert('XSS')\"></B></I></XML> <SPAN DATASRC=\"#xss\" DATAFLD=\"B\" DATAFORMATAS=\"HTML\"></SPAN>", "<DIV STYLE=\"background-image:\\0075\\0072\\006C\\0028'\\006a\\0061\\0076\\0061\\0073\\0063\\0072\\0069\\0070\\0074\\003a\\0061\\006c\\0065\\0072\\0074\\0028.1027\\0058.1053\\0053\\0027\\0029'\\0029\">", "<IMG SRC=javascript:alert('XSS')>", "';alert(String.fromCharCode(88,83,83))//\\';alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//\\\";alert(String.fromCharCode(88,83,83))//--></SCRIPT>\">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>", "<HTML><BODY> <?xml:namespace prefix=\"t\" ns=\"urn:schemas-microsoft-com:time\"> <?import namespace=\"t\" implementation=\"#default#time2\"> <t:set attributeName=\"innerHTML\" to=\"XSS<SCRIPT DEFER>alert("XSS")</SCRIPT>\"> </BODY></HTML>", "<EMBED SRC=\"data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==\" type=\"image/svg+xml\" AllowScriptAccess=\"always\"></EMBED>"] x = rand(4) case(x) when 0 return xss[rand(number)] when 1 return %|"| + xss[rand(number)] when 2 return %|">| + xss[rand(number)] when 3 return %|>| + xss[rand(number)] end end |
#tomorrow ⇒ Object
Returns an Integer object equal to tomorrow’s day of the month. The string is converted to an integer so as to remove the zero-padding from single-digit day values.
214 215 216 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 214 def tomorrow (Time.now + (3600*24)).strftime("%d").to_i end |
#yesterday ⇒ Object
Returns an Integer object equal to yesterday’s day of the month. The string is converted to an integer so as to remove the zero-padding from single-digit day values.
207 208 209 |
# File 'lib/kuali-sakai-common-lib/utilities.rb', line 207 def yesterday (Time.now - (3600*24)).strftime("%d").to_i end |