# Ruby

**URL:** https://www.ruby-forum.com/c/ruby/7.md?page=519

[Latest](https://www.ruby-forum.com/latest.md) · [Categories](https://www.ruby-forum.com/categories.md) · [Tags](https://www.ruby-forum.com/tags.md)

**Page:** 520

---

## [How do i configure this code](https://www.ruby-forum.com/t/how-do-i-configure-this-code/226084)

<div class="topic-metadata">

**Author:** [@amit-singh](https://www.ruby-forum.com/u/amit-singh)\
**Replies:** 0\
**Last updated:** [October 7, 2010, 2:36pm UTC](https://www.ruby-forum.com/t/how-do-i-configure-this-code/226084 "2010-10-07T14:36:36Z")

</div>

Hii all , This is code for mongrel http\_request.rb ,here i would like to close the Tempfile that was open in following line @body = Tempfile.new(Const::MONGREL\_TMP\_BASE) i tried with @body.close but i have to call at…

---

## [Why does Module#include exclude the module's metaclass?](https://www.ruby-forum.com/t/why-does-module-include-exclude-the-modules-metaclass/196120)

<div class="topic-metadata">

**Author:** [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Replies:** 10\
**Last updated:** [October 7, 2010, 2:27pm UTC](https://www.ruby-forum.com/t/why-does-module-include-exclude-the-modules-metaclass/196120 "2010-10-07T14:27:27Z")

</div>

When classes are inherited in Ruby the singleton classes are also inherited: class A def self.hello puts “hello” end end class B \< A end B.hello #=\> “hello” Yet with modules, this is not the case: module M de…

---

## [Looping through array starting at i !=0](https://www.ruby-forum.com/t/looping-through-array-starting-at-i-0/196111)

<div class="topic-metadata">

**Author:** [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Replies:** 2\
**Last updated:** [October 7, 2010, 1:02pm UTC](https://www.ruby-forum.com/t/looping-through-array-starting-at-i-0/196111 "2010-10-07T13:02:02Z")

</div>

Hi everyone, I want to loop through this array, but not for every index… only indices that are greater than 2. @weights.each\_index do |i| end Ted

---

## [Rescuing a function](https://www.ruby-forum.com/t/rescuing-a-function/196125)

<div class="topic-metadata">

**Author:** [@Courtland\_A](https://www.ruby-forum.com/u/Courtland_A)\
**Replies:** 5\
**Last updated:** [October 7, 2010, 12:55pm UTC](https://www.ruby-forum.com/t/rescuing-a-function/196125 "2010-10-07T12:55:35Z")

</div>

Hello, I’ve normally handled exceptions by “rescuing functions” in roughly this manner: def test\_function(args) puts “blah blah blah” rescue Exception=\>e puts “blah blah blah: #{args.inspect}” end However, I’m us…

---

## [Save only first line from string?](https://www.ruby-forum.com/t/save-only-first-line-from-string/195959)

<div class="topic-metadata">

**Author:** [@callyworld](https://www.ruby-forum.com/u/callyworld)\
**Replies:** 20\
**Last updated:** [October 7, 2010, 12:51pm UTC](https://www.ruby-forum.com/t/save-only-first-line-from-string/195959 "2010-10-07T12:51:29Z")

</div>

Hi. What’s the most simple and elegant way to remove all the contents of a String except for the first line? (Assume string consist of one line, multiple lines, or no lines, and assume that we don’t know which OS we a…

---

## [Testing if a script is run via sudo](https://www.ruby-forum.com/t/testing-if-a-script-is-run-via-sudo/196130)

<div class="topic-metadata">

**Author:** [@Une\_BSSSSvue](https://www.ruby-forum.com/u/Une_BSSSSvue)\
**Replies:** 6\
**Last updated:** [October 7, 2010, 12:08pm UTC](https://www.ruby-forum.com/t/testing-if-a-script-is-run-via-sudo/196130 "2010-10-07T12:08:45Z")

</div>

Is tehre a way to test if a ruby script is run as a sudoer user ? For the time being i’m using a zsh script to test that however I’d like using ruby only. the zsh i’m using : #! /usr/bin/env zsh \[ “$SUDO\_USER” -a id…

---

## [How do i close a file that is open in ruby](https://www.ruby-forum.com/t/how-do-i-close-a-file-that-is-open-in-ruby/196132)

<div class="topic-metadata">

**Author:** [@amit-singh](https://www.ruby-forum.com/u/amit-singh)\
**Replies:** 4\
**Last updated:** [October 7, 2010, 11:23am UTC](https://www.ruby-forum.com/t/how-do-i-close-a-file-that-is-open-in-ruby/196132 "2010-10-07T11:23:21Z")

</div>

Hi all, i would like to close a file that is open in particular directory .this is my code require ‘fileutils’ dir ="C:/Documents and Settings/x0138466/Local Settings/Temp" Dir.chdir(dir) Dir\["\*"\].each do |f| f.close…

---

## [Broken link check for Authenticated Url using http,uri](https://www.ruby-forum.com/t/broken-link-check-for-authenticated-url-using-http-uri/196012)

<div class="topic-metadata">

**Author:** [@pshah](https://www.ruby-forum.com/u/pshah)\
**Replies:** 1\
**Last updated:** [October 7, 2010, 9:44am UTC](https://www.ruby-forum.com/t/broken-link-check-for-authenticated-url-using-http-uri/196012 "2010-10-07T09:44:10Z")

</div>

Hi All, I work on check all links in a site, so for that i fetch all links from page and check its http response and its work fine for urls which have not any authentication. but my many urls need to pass username an…

---

## [XML-RPC WEBrick problem (error during method invocation)](https://www.ruby-forum.com/t/xml-rpc-webrick-problem-error-during-method-invocation/196076)

<div class="topic-metadata">

**Author:** [@moogmaster](https://www.ruby-forum.com/u/moogmaster)\
**Replies:** 9\
**Last updated:** [October 7, 2010, 7:15am UTC](https://www.ruby-forum.com/t/xml-rpc-webrick-problem-error-during-method-invocation/196076 "2010-10-07T07:15:31Z")

</div>

I have a university assignement, and i am stuck. I am supposed to create a server using xml-rpc with ruby, but I keep getting errors. I am not very good with ruby, this is actually the first time im working on a ruby …

---

## [Missing @ for instace variable in class, but no error message](https://www.ruby-forum.com/t/missing-for-instace-variable-in-class-but-no-error-message/196115)

<div class="topic-metadata">

**Author:** [@stefans](https://www.ruby-forum.com/u/stefans)\
**Replies:** 5\
**Last updated:** [October 7, 2010, 5:17am UTC](https://www.ruby-forum.com/t/missing-for-instace-variable-in-class-but-no-error-message/196115 "2010-10-07T05:17:58Z")

</div>

Some days ago I was defining a class, but forgot to use the leading @ for an instance variable. But it still works – that variable was made accessible by attr\_accessor statement. So my question: Why gives the statemen…

---

## [How do i detect END OF FILE file in ruby](https://www.ruby-forum.com/t/how-do-i-detect-end-of-file-file-in-ruby/196069)

<div class="topic-metadata">

**Author:** [@amit-singh](https://www.ruby-forum.com/u/amit-singh)\
**Replies:** 3\
**Last updated:** [October 7, 2010, 3:33am UTC](https://www.ruby-forum.com/t/how-do-i-detect-end-of-file-file-in-ruby/196069 "2010-10-07T03:33:46Z")

</div>

Hi all, i would like to know how do i detect END OF FILE file in ruby.is there any EOF operator in ruby???

---

## [Error when using class variables with operators](https://www.ruby-forum.com/t/error-when-using-class-variables-with-operators/196100)

<div class="topic-metadata">

**Author:** [@prichard](https://www.ruby-forum.com/u/prichard)\
**Replies:** 6\
**Last updated:** [October 6, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/error-when-using-class-variables-with-operators/196100 "2010-10-06T23:59:43Z")

</div>

Hi. When I use class variables with operators I get the following error message… undefined method \`\>’ for nil:NilClass here’s a piece of code that gives this error… if @@target1 \< @@target2 @@status = true

---

## [Urgent help needed! unable to locate syntax errors](https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104)

<div class="topic-metadata">

**Author:** [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Replies:** 2\
**Last updated:** [October 6, 2010, 10:28pm UTC](https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104 "2010-10-06T22:28:13Z")

</div>

Please find the txt file for the ruby program attached. I have the following errors…Please help someone…! Error Loading File slab.rb C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/slab.rb:408: syntax error …

---

## [October Phoenix Ruby User Group Meeting](https://www.ruby-forum.com/t/october-phoenix-ruby-user-group-meeting/196109)

<div class="topic-metadata">

**Author:** [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Replies:** 0\
**Last updated:** [October 6, 2010, 10:02pm UTC](https://www.ruby-forum.com/t/october-phoenix-ruby-user-group-meeting/196109 "2010-10-06T22:02:28Z")

</div>

October Phoenix Ruby U. Group Meeting When: Monday, October 11, 2010 6:30pm door open. Laptop power and WiFi available. 7:00pm Show time 8:30pm Migrate to Four Peaks Brewery Topic: Git! Greg Furmanek will t…

---

## [Pass by reference and copy on write](https://www.ruby-forum.com/t/pass-by-reference-and-copy-on-write/195928)

<div class="topic-metadata">

**Author:** [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Replies:** 23\
**Last updated:** [October 6, 2010, 9:44pm UTC](https://www.ruby-forum.com/t/pass-by-reference-and-copy-on-write/195928 "2010-10-06T21:44:53Z")

</div>

I see Pass by reference or pass by value - Rails - Ruby-Forum which has a fairly long explanation of passing stuff by reference and copy on write(cow). Let’s say I have def som\_func(x,y) x = 24 y = 42 end . . a…

---

## [Re: interesting irb experiment](https://www.ruby-forum.com/t/re-interesting-irb-experiment/196103)

<div class="topic-metadata">

**Author:** [@DaShiellS\_Jude\_TSS](https://www.ruby-forum.com/u/DaShiellS_Jude_TSS)\
**Replies:** 0\
**Last updated:** [October 6, 2010, 9:32pm UTC](https://www.ruby-forum.com/t/re-interesting-irb-experiment/196103 "2010-10-06T21:32:35Z")

</div>

Brian, thanks for the reminder on rand() notation, I was able to use that and get everything working.

---

## [Error defining UI\_need help urgently](https://www.ruby-forum.com/t/error-defining-ui-need-help-urgently/196068)

<div class="topic-metadata">

**Author:** [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Replies:** 3\
**Last updated:** [October 6, 2010, 9:19pm UTC](https://www.ruby-forum.com/t/error-defining-ui-need-help-urgently/196068 "2010-10-06T21:19:07Z")

</div>

Please find the .txt file attached. I have been trying to build a conceptual design program for slabs using RUBY for Sketchup and have been getting some syntax error messages as shown below. Please help somebody! than…

---

## [Interesting irb experiment](https://www.ruby-forum.com/t/interesting-irb-experiment/196096)

<div class="topic-metadata">

**Author:** [@DaShiellS\_Jude\_TSS](https://www.ruby-forum.com/u/DaShiellS_Jude_TSS)\
**Replies:** 2\
**Last updated:** [October 6, 2010, 8:39pm UTC](https://www.ruby-forum.com/t/interesting-irb-experiment/196096 "2010-10-06T20:39:19Z")

</div>

J=126rand+33.round K=j.chr Works as far as it goes, however J=126rand+33.round.chr Throws an error. The actual error message seems strange after .round did its work.

---

## [The beauty of Ruby through examples](https://www.ruby-forum.com/t/the-beauty-of-ruby-through-examples/195768)

<div class="topic-metadata">

**Author:** [@Adriano\_F](https://www.ruby-forum.com/u/Adriano_F)\
**Replies:** 32\
**Last updated:** [October 6, 2010, 7:47pm UTC](https://www.ruby-forum.com/t/the-beauty-of-ruby-through-examples/195768 "2010-10-06T19:47:49Z")

</div>

Hey all, I’m about to introduce Ruby to a group of people that is not familiar to the language, and the approach i’d like to take is simply by distilling out a few sample codes. I’ve been collecting some from around…

---

## [UnboundMethod#source\_location in Ruby 1.8.7](https://www.ruby-forum.com/t/unboundmethod-source-location-in-ruby-1-8-7/196095)

<div class="topic-metadata">

**Author:** [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Replies:** 0\
**Last updated:** [October 6, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/unboundmethod-source-location-in-ruby-1-8-7/196095 "2010-10-06T19:33:46Z")

</div>

Any way to emulate UnboundMethod#source\_location in Ruby 1.8.7? I am working on a tool that uses this feature and I am wondering how I can make it work for older version of Ruby as well. Thanks.

---

## [Progromatic download of rpm file](https://www.ruby-forum.com/t/progromatic-download-of-rpm-file/196093)

<div class="topic-metadata">

**Author:** [@Jedrin](https://www.ruby-forum.com/u/Jedrin)\
**Replies:** 1\
**Last updated:** [October 6, 2010, 7:24pm UTC](https://www.ruby-forum.com/t/progromatic-download-of-rpm-file/196093 "2010-10-06T19:24:24Z")

</div>

not sure why neither of these ways to download an rpm from ruby don’t work, but if I use a web broswer on the same url there’s no problem … require ‘net/http’ Net::HTTP.start(“apt.sw.be”) { |http| resp = http.get(“…

---

## [RDoc doesn't create diagrams](https://www.ruby-forum.com/t/rdoc-doesnt-create-diagrams/196090)

<div class="topic-metadata">

**Author:** [@zapotek](https://www.ruby-forum.com/u/zapotek)\
**Replies:** 0\
**Last updated:** [October 6, 2010, 5:52pm UTC](https://www.ruby-forum.com/t/rdoc-doesnt-create-diagrams/196090 "2010-10-06T17:52:24Z")

</div>

Hi guys, I’m having a problem with rdoc. When I use the --diagrams CLI argument no diagrams are generated without any notification or error message. ruby 1.9.2p0 (2010-08-18) \[x86\_64-linux\] rdoc 2.5.8 Does anyone h…

---

## [Tooltip with css\_tt](https://www.ruby-forum.com/t/tooltip-with-css-tt/196023)

<div class="topic-metadata">

**Author:** [@upabibi](https://www.ruby-forum.com/u/upabibi)\
**Replies:** 3\
**Last updated:** [October 6, 2010, 5:51pm UTC](https://www.ruby-forum.com/t/tooltip-with-css-tt/196023 "2010-10-06T17:51:54Z")

</div>

Using “css\_tt” gem, I was able to create a tooltip. However, my text (of the tooltip) has many “ ”. Here’s my view: \<% @tooltip = "Whatever This is just an example I need many break lines Got it?" %\> \<%= css…

---

## [Runtime evaluation of variables](https://www.ruby-forum.com/t/runtime-evaluation-of-variables/196089)

<div class="topic-metadata">

**Author:** [@Romaric\_ludinard\_R](https://www.ruby-forum.com/u/Romaric_ludinard_R)\
**Replies:** 0\
**Last updated:** [October 6, 2010, 5:46pm UTC](https://www.ruby-forum.com/t/runtime-evaluation-of-variables/196089 "2010-10-06T17:46:29Z")

</div>

Hi there, I’m currently working with ruby and set\_trace\_func function. I need to find local\_variables, instance\_variables and method parameters. for local variables and instance variables, something like that works : …

---

## [The Third Ruby - Ever Comes Out at Night?](https://www.ruby-forum.com/t/the-third-ruby-ever-comes-out-at-night/195900)

<div class="topic-metadata">

**Author:** [@mschwab](https://www.ruby-forum.com/u/mschwab)\
**Replies:** 18\
**Last updated:** [October 6, 2010, 1:53pm UTC](https://www.ruby-forum.com/t/the-third-ruby-ever-comes-out-at-night/195900 "2010-10-06T13:53:45Z")

</div>

Often you see that Ruby can be object-oriented, functional or procedural. What would you expect to see in a program that made you say “Ah this is procedural Ruby!”?

---

## [Need help installing Appscript on MAC OSX 10.4.11 Power PC](https://www.ruby-forum.com/t/need-help-installing-appscript-on-mac-osx-10-4-11-power-pc/195811)

<div class="topic-metadata">

**Author:** [@jalbers](https://www.ruby-forum.com/u/jalbers)\
**Replies:** 1\
**Last updated:** [October 6, 2010, 11:00am UTC](https://www.ruby-forum.com/t/need-help-installing-appscript-on-mac-osx-10-4-11-power-pc/195811 "2010-10-06T11:00:22Z")

</div>

I downloaded appscript and it is unzipped. I started up terminal and changed directories to the folder rb-appscript-0.5.3 and I think that I need to do the following three commands to get it installed: ruby extconf.r…

---

## [Sorting problem with an Array of Arrays](https://www.ruby-forum.com/t/sorting-problem-with-an-array-of-arrays/195417)

<div class="topic-metadata">

**Author:** [@paul](https://www.ruby-forum.com/u/paul)\
**Replies:** 16\
**Last updated:** [October 6, 2010, 10:38am UTC](https://www.ruby-forum.com/t/sorting-problem-with-an-array-of-arrays/195417 "2010-10-06T10:38:41Z")

</div>

Hi there, I have an array of arrays that looks like the following: arr1 = \[\[“ABC-1”, 1271768400, 2\], \[“ABC-2”, 1271773800, 1\], \[“ABC-3”, 1271863200, 2\], \[“ABC-4”, 1271869200, 2\], \[“AAA-1”, 1271862000, 2\], \[“DEF-1”,…

---

## [Confused: instances or arrays?](https://www.ruby-forum.com/t/confused-instances-or-arrays/196056)

<div class="topic-metadata">

**Author:** [@prichard](https://www.ruby-forum.com/u/prichard)\
**Replies:** 2\
**Last updated:** [October 6, 2010, 9:53am UTC](https://www.ruby-forum.com/t/confused-instances-or-arrays/196056 "2010-10-06T09:53:01Z")

</div>

Hi. I want to create the following class… Client attributes name, amount\_wealth, loans, lender, bankrupt (a boolean) methods is\_client\_solvent? (I declare the client bankrupt if total amount of loans is greater tha…

---

## [Writing a Nim game in ruby](https://www.ruby-forum.com/t/writing-a-nim-game-in-ruby/196048)

<div class="topic-metadata">

**Author:** [@kingkuan](https://www.ruby-forum.com/u/kingkuan)\
**Replies:** 2\
**Last updated:** [October 6, 2010, 9:49am UTC](https://www.ruby-forum.com/t/writing-a-nim-game-in-ruby/196048 "2010-10-06T09:49:33Z")

</div>

wondering does anyone know how to help with this problem n and t should be constants in your program, but give them better names like INITIAL\_NUM\_MATCHES and MAX\_ALLOWED\_TO\_TAKE. You may assume that the user plays fir…

---

## [How do i delete files in particular directoryin ruby?](https://www.ruby-forum.com/t/how-do-i-delete-files-in-particular-directoryin-ruby/195971)

<div class="topic-metadata">

**Author:** [@amit-singh](https://www.ruby-forum.com/u/amit-singh)\
**Replies:** 23\
**Last updated:** [October 6, 2010, 7:41am UTC](https://www.ruby-forum.com/t/how-do-i-delete-files-in-particular-directoryin-ruby/195971 "2010-10-06T07:41:46Z")

</div>

Hii all, i would like to know ,how do i delete all files in particular directoy .i don’t know about name of files but i know from which directory i have to delete files.how should i do that??

[Previous page](https://www.ruby-forum.com/c/ruby/7.md?page=518)

[Next page](https://www.ruby-forum.com/c/ruby/7.md?page=520)
