# Ruby

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

[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:** 1377

---

## [De-camelcase a filename](https://www.ruby-forum.com/t/de-camelcase-a-filename/108232)

<div class="topic-metadata">

**Author:** [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Replies:** 16\
**Last updated:** [August 28, 2007, 5:52am UTC](https://www.ruby-forum.com/t/de-camelcase-a-filename/108232 "2007-08-28T05:52:58Z")

</div>

how can a take a string file name like MyTestCase.rb and change it to my\_test\_case.rb? thanks

---

## [Flog 1.1.0 Released](https://www.ruby-forum.com/t/flog-1-1-0-released/112603)

<div class="topic-metadata">

**Author:** [@aguynamedryan](https://www.ruby-forum.com/u/aguynamedryan)\
**Replies:** 11\
**Last updated:** [August 28, 2007, 5:32am UTC](https://www.ruby-forum.com/t/flog-1-1-0-released/112603 "2007-08-28T05:32:57Z")

</div>

flog version 1.1.0 has been released! http://ruby.sadi.st/ http://rubyforge.org/projects/seattlerb Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is i…

---

## [Why does: system("./ati-driver-installer-8.40.4-x86.x86\_64.r](https://www.ruby-forum.com/t/why-does-system-ati-driver-installer-8-40-4-x86-x86-64-r/113041)

<div class="topic-metadata">

**Author:** [@kazaam](https://www.ruby-forum.com/u/kazaam)\
**Replies:** 10\
**Last updated:** [August 28, 2007, 3:24am UTC](https://www.ruby-forum.com/t/why-does-system-ati-driver-installer-8-40-4-x86-x86-64-r/113041 "2007-08-28T03:24:48Z")

</div>

Well, while I thought I could finish my script for installing an ati-driver today I wanted to test it now but I have this problem mentioned in the subject. My ruby-script ist started with sudo ./ati.rb so it has the …

---

## [How to check for block in an evaled method?](https://www.ruby-forum.com/t/how-to-check-for-block-in-an-evaled-method/113060)

<div class="topic-metadata">

**Author:** [@Nasir\_K](https://www.ruby-forum.com/u/Nasir_K)\
**Replies:** 3\
**Last updated:** [August 28, 2007, 1:42am UTC](https://www.ruby-forum.com/t/how-to-check-for-block-in-an-evaled-method/113060 "2007-08-28T01:42:43Z")

</div>

Consider the snippet - class B def set B.class\_eval do define\_method(:a) do |arg| if block\_given? yield else “hello” end end end end end The intention is that block\_given? would tell me if the new method a(…

---

## [What is happening with this Unary minus?](https://www.ruby-forum.com/t/what-is-happening-with-this-unary-minus/113097)

<div class="topic-metadata">

**Author:** [@toadkicker](https://www.ruby-forum.com/u/toadkicker)\
**Replies:** 3\
**Last updated:** [August 27, 2007, 11:23pm UTC](https://www.ruby-forum.com/t/what-is-happening-with-this-unary-minus/113097 "2007-08-27T23:23:33Z")

</div>

LOOPER = 6 -(LOOPER).upto(LOOPER) {|i| puts i } I get one line of output: 6 However, I get 13 lines of output here: (-LOOPER).upto(LOOPER) {|i| puts i } What is happening with the unary minus on the first example…

---

## [Sort\_by { rand } not working](https://www.ruby-forum.com/t/sort-by-rand-not-working/113032)

<div class="topic-metadata">

**Author:** [@miked](https://www.ruby-forum.com/u/miked)\
**Replies:** 21\
**Last updated:** [August 27, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/sort-by-rand-not-working/113032 "2007-08-27T22:37:05Z")

</div>

Hello: I’ve got an array of arrays that I’d like to sort\_by random. each individual array is just a hash of a value and then an object. Is there some reason why sort\_by { rand } wouldn’t work? My code is simple (tea…

---

## [Number of seconds as English duration](https://www.ruby-forum.com/t/number-of-seconds-as-english-duration/113118)

<div class="topic-metadata">

**Author:** [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Replies:** 0\
**Last updated:** [August 27, 2007, 8:17pm UTC](https://www.ruby-forum.com/t/number-of-seconds-as-english-duration/113118 "2007-08-27T20:17:07Z")

</div>

I ported a function I once wrote in JavaScript (Index of /JS/ Date.prototype.asDuration.js) over to Ruby today. I submit it below for your review, criticism, and general code sharing. (If I had cause to use this with …

---

## [Mms2r 1.1.7 Released](https://www.ruby-forum.com/t/mms2r-1-1-7-released/113116)

<div class="topic-metadata">

**Author:** [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Replies:** 0\
**Last updated:** [August 27, 2007, 8:03pm UTC](https://www.ruby-forum.com/t/mms2r-1-1-7-released/113116 "2007-08-27T20:03:06Z")

</div>

mms2r version 1.1.7 has been released! http://mms2r.rubyforge.org/ DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone carriers…

---

## [Changing/Setting Passwords in Active Directory](https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094)

<div class="topic-metadata">

**Author:** [@Glen\_H](https://www.ruby-forum.com/u/Glen_H)\
**Replies:** 2\
**Last updated:** [August 27, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/changing-setting-passwords-in-active-directory/113094 "2007-08-27T17:44:49Z")

</div>

I’ve been doing some searching but am not faring so well. Does anyone know a clean and reliable way to change and or set passwords for Windows accounts residing in Active Directory? I’d rather not have to generate a …

---

## [Bind to an "as if" superclass context](https://www.ruby-forum.com/t/bind-to-an-as-if-superclass-context/112989)

<div class="topic-metadata">

**Author:** [@Trans](https://www.ruby-forum.com/u/Trans)\
**Replies:** 4\
**Last updated:** [August 27, 2007, 5:08pm UTC](https://www.ruby-forum.com/t/bind-to-an-as-if-superclass-context/112989 "2007-08-27T17:08:46Z")

</div>

Is there a way to do the “opposite” of binding a superclass method to the current context? In other words, I want to call a method as if the current binding were an instance of the superclass. For example, using the m…

---

## [How to best extract Ruby strings from REXML::Text instances?](https://www.ruby-forum.com/t/how-to-best-extract-ruby-strings-from-rexml-text-instances/113006)

<div class="topic-metadata">

**Author:** [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Replies:** 1\
**Last updated:** [August 27, 2007, 4:53pm UTC](https://www.ruby-forum.com/t/how-to-best-extract-ruby-strings-from-rexml-text-instances/113006 "2007-08-27T16:53:45Z")

</div>

REXML is a great package and is making it very easy for me to extract data from web pages. However, I’m having trouble with extracting a file string value from text nodes. My understanding from reading the API doc is …

---

## [Bug in ri\_formatter.rb](https://www.ruby-forum.com/t/bug-in-ri-formatter-rb/112976)

<div class="topic-metadata">

**Author:** [@pedz](https://www.ruby-forum.com/u/pedz)\
**Replies:** 2\
**Last updated:** [August 27, 2007, 3:20pm UTC](https://www.ruby-forum.com/t/bug-in-ri-formatter-rb/112976 "2007-08-27T15:20:34Z")

</div>

If you do ri of Rail’s option\_groups\_from\_collection\_for\_select, whose complete name is ActionView::Helpers::FormOptionsHelper#option\_groups\_from\_collection\_for\_select, then ri\_formatter.rb throws an error at line 18: …

---

## [Install Ldap on windows XP + instant Rail](https://www.ruby-forum.com/t/install-ldap-on-windows-xp-instant-rail/112927)

<div class="topic-metadata">

**Author:** [@shyamydv](https://www.ruby-forum.com/u/shyamydv)\
**Replies:** 2\
**Last updated:** [August 27, 2007, 9:32am UTC](https://www.ruby-forum.com/t/install-ldap-on-windows-xp-instant-rail/112927 "2007-08-27T09:32:05Z")

</div>

Hello guys , I am new in Ruby on rails , I have installed Ruby+rails+gem +mysql+oracle , from instant rail package installer now i want to run ldap on my windows system , so please help me how i can do that please …

---

## [Dir, recursive filescan](https://www.ruby-forum.com/t/dir-recursive-filescan/112931)

<div class="topic-metadata">

**Author:** [@RebhanS\_Gilbert](https://www.ruby-forum.com/u/RebhanS_Gilbert)\
**Replies:** 4\
**Last updated:** [August 27, 2007, 9:01am UTC](https://www.ruby-forum.com/t/dir-recursive-filescan/112931 "2007-08-27T09:01:41Z")

</div>

Hi, i want to count the occurence of a searchstring in all files below a directory and all its subdirectories i have = matches=0 Dir.glob(“E:/test/foobar/scripts//.xml”).each do |f| matches += File.new(f).read.scan…

---

## [Override object initialization, add a filepath attribute](https://www.ruby-forum.com/t/override-object-initialization-add-a-filepath-attribute/113068)

<div class="topic-metadata">

**Author:** [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Replies:** 4\
**Last updated:** [August 27, 2007, 8:55am UTC](https://www.ruby-forum.com/t/override-object-initialization-add-a-filepath-attribute/113068 "2007-08-27T08:55:16Z")

</div>

Is it possible to override initializations so that anytime an object is created there is a “filepath” attribute put on it? maybe? class Object def initialize super class \<\< self attr\_accessor :filepath end self.…

---

## [If assignment is a method call](https://www.ruby-forum.com/t/if-assignment-is-a-method-call/113056)

<div class="topic-metadata">

**Author:** [@Nasir\_K](https://www.ruby-forum.com/u/Nasir_K)\
**Replies:** 1\
**Last updated:** [August 27, 2007, 8:40am UTC](https://www.ruby-forum.com/t/if-assignment-is-a-method-call/113056 "2007-08-27T08:40:36Z")

</div>

Given an object x, if you invoke x.y = 1 then this will work if the object has an attribute y and is writable (or you have defined a method y= ) If that is not the case then you will get a NoMethodError. You can over…

---

## [\[SOLUTION\] ID3 Tags (#136)](https://www.ruby-forum.com/t/solution-id3-tags-136/113055)

<div class="topic-metadata">

**Author:** [@jameskelly](https://www.ruby-forum.com/u/jameskelly)\
**Replies:** 1\
**Last updated:** [August 27, 2007, 7:11am UTC](https://www.ruby-forum.com/t/solution-id3-tags-136/113055 "2007-08-27T07:11:22Z")

</div>

$genres = \[“Blues”,“Classic Rock”,“Country”,“Dance”,“Disco”,“Funk”, “Grunge”,“Hip-Hop”,“Jazz”,“Metal”,“New Age”,“Oldies”, “Other”,“Pop”,“R&B”,“Rap”,“Reggae”,“Rock”,“Techno”, “Industrial”,“Alternative”,“Ska”,“Death Met…

---

## [Gosu](https://www.ruby-forum.com/t/gosu/113066)

<div class="topic-metadata">

**Author:** [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Replies:** 0\
**Last updated:** [August 27, 2007, 5:51am UTC](https://www.ruby-forum.com/t/gosu/113066 "2007-08-27T05:51:50Z")

</div>

Hey everyone, I’m playing around with the Gosu game library now. (no pun intended) It’s not bad at all. The tutorial makes some things pretty self explanatory. (though it could use some more details, but what tutoria…

---

## [Each\_byte and break](https://www.ruby-forum.com/t/each-byte-and-break/113059)

<div class="topic-metadata">

**Author:** [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Replies:** 0\
**Last updated:** [August 27, 2007, 4:04am UTC](https://www.ruby-forum.com/t/each-byte-and-break/113059 "2007-08-27T04:04:27Z")

</div>

each\_byte e$B$+$ie(B break e$B$9$k$HFI$s$@$b$N$,$^$?FI$a$k$3$H$,$"$je(B e$B$^$9!#e(B % echo abcdef |./ruby -ve ‘STDIN.each\_byte {|b| p b; break if b == 100 }; p STDIN.read’ ruby 1.9.0 (2007-08-27 patchlevel 0) \[i686-…

---

## [How to append some data at the beginning of a file](https://www.ruby-forum.com/t/how-to-append-some-data-at-the-beginning-of-a-file/112910)

<div class="topic-metadata">

**Author:** [@uday](https://www.ruby-forum.com/u/uday)\
**Replies:** 9\
**Last updated:** [August 27, 2007, 3:59am UTC](https://www.ruby-forum.com/t/how-to-append-some-data-at-the-beginning-of-a-file/112910 "2007-08-27T03:59:24Z")

</div>

Hi, I am newbie to Ruby so please spare me if the question looks silly. My question is how to append data at the beginning of a file? Suppose I have a file named test.rb which contains some text, say “This is first l…

---

## [Ruport 1.2 pre-release, please help test!](https://www.ruby-forum.com/t/ruport-1-2-pre-release-please-help-test/196448)

<div class="topic-metadata">

**Author:** [@naething](https://www.ruby-forum.com/u/naething)\
**Replies:** 0\
**Last updated:** [August 27, 2007, 3:21am UTC](https://www.ruby-forum.com/t/ruport-1-2-pre-release-please-help-test/196448 "2007-08-27T03:21:17Z")

</div>

Hi folks, It’s been a while since we’ve done a major Ruport release (1.0 in mid- May), but we’ve been busy behind the scenes. Ruport 1.2 is just about ready and includes a boat load of changes and enhancements. What…

---

## [How can I make this if/else more succinct?](https://www.ruby-forum.com/t/how-can-i-make-this-if-else-more-succinct/112974)

<div class="topic-metadata">

**Author:** [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Replies:** 12\
**Last updated:** [August 27, 2007, 2:36am UTC](https://www.ruby-forum.com/t/how-can-i-make-this-if-else-more-succinct/112974 "2007-08-27T02:36:02Z")

</div>

How can I make this if/else more succinct? Video.find(:all).each do |video| if video.\_3gp ext=".3gp" elsif video.\_3g2 ext=".3g2" elsif video.mp4 ext=".mp4" end

---

## [Suppress ruby warnings during runtime?](https://www.ruby-forum.com/t/suppress-ruby-warnings-during-runtime/112878)

<div class="topic-metadata">

**Author:** [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Replies:** 3\
**Last updated:** [August 27, 2007, 12:45am UTC](https://www.ruby-forum.com/t/suppress-ruby-warnings-during-runtime/112878 "2007-08-27T00:45:24Z")

</div>

I’ve been looking for a way to supress warnings at runtime, not just in the shebang line… I’ve tride setting $VERBOSE = nil but that doesn’t seem to work right. Specifically i’m getting warnings when accessing Object#…

---

## [Adding aspects that modify return values?](https://www.ruby-forum.com/t/adding-aspects-that-modify-return-values/112539)

<div class="topic-metadata">

**Author:** [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Replies:** 2\
**Last updated:** [August 27, 2007, 12:27am UTC](https://www.ruby-forum.com/t/adding-aspects-that-modify-return-values/112539 "2007-08-27T00:27:48Z")

</div>

I am trying to use ‘aspectr’ to add aspects to Rails FormHelpers like ‘text\_field’. I want the aspects to be able to intercept the return value and modify it so that the original method call ‘text\_field’ returns the …

---

## [Strict conversion of strings to ints?](https://www.ruby-forum.com/t/strict-conversion-of-strings-to-ints/113016)

<div class="topic-metadata">

**Author:** [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Replies:** 7\
**Last updated:** [August 26, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/strict-conversion-of-strings-to-ints/113016 "2007-08-26T23:43:14Z")

</div>

Is there an easy way to parse a string to an integer that will throw an error of some sort if the string is not actually a properly formatted integer? “to\_i” of course is very non-strict, which is no good for what I w…

---

## [Class X \< Hash ... how do I do X.new { |hash, key| ...}?](https://www.ruby-forum.com/t/class-x-hash-how-do-i-do-x-new-hash-key/113009)

<div class="topic-metadata">

**Author:** [@lfast](https://www.ruby-forum.com/u/lfast)\
**Replies:** 3\
**Last updated:** [August 26, 2007, 10:24pm UTC](https://www.ruby-forum.com/t/class-x-hash-how-do-i-do-x-new-hash-key/113009 "2007-08-26T22:24:26Z")

</div>

I created a child class of Hash and would like to internalize the equivalent of Hash.new {|hash,key| } The following code failed: class X \< Hash def initialize super { |hash,key| … } end end Any suggestions? I …

---

## [Fwd: Please Forward: Ruby Quiz Submission](https://www.ruby-forum.com/t/fwd-please-forward-ruby-quiz-submission/229154)

<div class="topic-metadata">

**Author:** [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Replies:** 0\
**Last updated:** [August 26, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/fwd-please-forward-ruby-quiz-submission/229154 "2007-08-26T20:19:26Z")

</div>

Begin forwarded message:

---

## [Finding one certain line in a file is easy but how to look f](https://www.ruby-forum.com/t/finding-one-certain-line-in-a-file-is-easy-but-how-to-look-f/113030)

<div class="topic-metadata">

**Author:** [@kazaam](https://www.ruby-forum.com/u/kazaam)\
**Replies:** 3\
**Last updated:** [August 26, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/finding-one-certain-line-in-a-file-is-easy-but-how-to-look-f/113030 "2007-08-26T17:36:06Z")

</div>

Hi, I’m writing a little script for installing ati-drivers on linux machines but I have a little problem. I need to change the /etc/X11/xorg.conf file for this. This file is built like this (just a cut-out): Section …

---

## [String interpolation](https://www.ruby-forum.com/t/string-interpolation/113022)

<div class="topic-metadata">

**Author:** [@wet](https://www.ruby-forum.com/u/wet)\
**Replies:** 4\
**Last updated:** [August 26, 2007, 5:14pm UTC](https://www.ruby-forum.com/t/string-interpolation/113022 "2007-08-26T17:14:01Z")

</div>

a = 5 b = “#{a}” puts b a = 6 puts b Returns: 5 5 which is clear to me, why. But is there a way to define such a string and interpolate it at a later time? Thomas

---

## [Newbie questions](https://www.ruby-forum.com/t/newbie-questions/113002)

<div class="topic-metadata">

**Author:** [@BarrS\_Keith](https://www.ruby-forum.com/u/BarrS_Keith)\
**Replies:** 9\
**Last updated:** [August 26, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/newbie-questions/113002 "2007-08-26T16:33:54Z")

</div>

Hi there, I am new to using Ruby and I am writing my first real programs and I have something I was wonndering about: I have a menu that I would like users to respond to simply by entering a single character. I have…

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

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