{"id":131,"date":"2007-08-14T22:34:38","date_gmt":"2007-08-14T22:34:38","guid":{"rendered":"http:\/\/rrbits.com\/epb\/?p=131"},"modified":"2011-02-06T17:40:27","modified_gmt":"2011-02-06T23:40:27","slug":"my-first-script-in-ruby","status":"publish","type":"post","link":"https:\/\/rrbits.com\/epb\/2007\/08\/14\/my-first-script-in-ruby\/","title":{"rendered":"My first script in Ruby"},"content":{"rendered":"<p>I decided that I wanted to learn Ruby, but I&#8217;m not much of a reader.  Far too impatient, so I figured I&#8217;d jump into some code and write something.  The result was a random number generator.  It&#8217;s not great, but it does the job.  Pick a minimum and maximum number, and it will generate them.<!--more--><\/p>\n<p><code> #Random number generator script.another = \"y\"<br \/>\nwhile another[\/^y\/] == \"y\" or another[\/^Y\/] == \"Y\"<\/p>\n<p>#Request the minimum<br \/>\nprint \"Enter minimum number: \";<br \/>\nmin = readline();<\/p>\n<p>print \"Enter maximum number: \";<br \/>\nmax = readline();<\/p>\n<p>if min.to_i() &gt; max.to_i()<br \/>\n# Max is greater than Min, switch them.<br \/>\ntemp = min;<br \/>\nmin = max;<br \/>\nmax = temp;<br \/>\nend<\/p>\n<p>#calculate the base number.<br \/>\n#  E.g: 3 - 7 yields<br \/>\n#a possible return of 5 numbers. 3, 4, 5, 6, and 7<\/p>\n<p>base = max.to_i() - min.to_i() + 1;<\/p>\n<p>#Seed the random number generator.<br \/>\nsrand(Time.now.to_i());<\/p>\n<p>print rand(base)+min.to_i();<\/p>\n<p>print \"\\nDo another? :\"<br \/>\nanother = readline();<\/p>\n<p>end<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I decided that I wanted to learn Ruby, but I&#8217;m not much of a reader. Far too impatient, so I figured I&#8217;d jump into some code and write something. The result was a random number generator. It&#8217;s not great, but it does the job. Pick a minimum and maximum number, and it will generate them.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[147],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-ruby"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":1,"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/posts\/131\/revisions\/303"}],"wp:attachment":[{"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rrbits.com\/epb\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}