312670-410612 subjects 313027-364904

unit testing with class and floats
312835 [adamtemporar] im learning unit testing and have just recently started using classes
312836 [adamtemporar] sorry a (simplified) example
312838 [farrel.lifso] When comparing floats there is a chance that although the floats might
+ 312841 [B.Candler@po] (Two floats which look the same when printed may actually be slightly
+ 312923 [adamtemporar] ahhh i thought you could only use assert_in_delta with only floats

Difficult Inheritance Problem
312839 [tobyclemson@] I have a problem I can't think of a solution to with regard to
+ 312842 [boesemar@gm ] I am using something like below for my program. I trick is to use methods
+ 312843 [jcoglan@go g] ...
+ 312844 [frederick.ch] two possible approaches are rails' class_inheritable_accessor and
+ 312846 [robert.dober] I am currently working on a new release of Labardor, but there still
+ 312848 [dblack@ru yp] class Page
| + 312850 [jcoglan@go g] ...
| | + 312851 [dblack@ru yp] True, but the OP described it as: "Is there a way to define a class
| | + 313158 [ninja@sl ph ] class Page
| |   313650 [tobyclemson@] Thank you all for your responses. I ended up using James Coglan's
| |   313657 [shortcutter@] I believe there is a better approach that solves the inheritance issue
| + 312852 [robert.dober] Wow that is great, I would call them viral class variables!
|   312854 [dblack@ru yp] I think class variables are already viral :-)
|   312877 [robert.dober] Well they are unique, applying your pattern however the following holds
+ 312929 [vjoel@pa h. ] Sorry for the crappy docs. It's an old project, but I use it frequently.

Re: split not returning an array?
312845 [B.Candler@po] Because it is defined in the specification for URLs that + means space.

syntax error, unexpected kELSE
312853 [christopher.] I've been trying to solve the problem in the following bit of code for
+ 312856 [dblack@ru yp] There's no ++ increment operator. Change that to z += 1.
+ 312857 [jgabrielygal] Ruby doesn't support this syntax. Change it to z += 1.
| 312859 [christopher.] Thanks a million guys, I go back and forth with languages and didn't
| 312861 [dblack@ru yp] ...
| 312883 [davebass@mu ] As the ++ and -- notations are so common in other languages, and some of
| 313188 [dblack@ru yp] I don't think so. I prefer not to have Ruby apologize for not being
+ 312893 [shortcutter@] Apart from the ++ issue you might want to change other things as well.

Problemm using ruby classes
312855 [marchese58@l] I'm new on ruby so probably my question is stupid.
+ 312872 [stefano.croc] You need to require the file where you defined the class. For example
| 312884 [shevegen@li ] To make it known you need to
+ 312957 [sepp2k@go gl] .new is not an operator it is nothing more than a simple method call.
  312993 [marchese58@l] Thanks to everyone, i solved the problem!

resizing images in rails?
312864 [ravivardhank] how to resize the images in rails app?
+ 312869 [rmagick@gm i] the section "Resizing to a maximum (or minimum) size".
+ 313019 [uzimonkey@gm] First, resizing 400x300 to 600x800 changes the aspect ratio.  The image

wsdl2ruby proxy aware?
312865 [rajmohan@mo ] ...

Re: ActiveRecord Question -- making arrays or hashs out of database tables
312870 [glenn_ritz@y] ...

encrypting password on form submit?
312875 [a.etherton@h] information from the form is currently submitted to the database as is.
+ 312876 [jcoglan@go g] ...
| 312878 [a.etherton@h] Thanks for your response, but do you know of a way to just encrypt the
| + 312879 [jcoglan@go g] ...
| + 312880 [fophillips@f] =20
|   + 312881 [a.etherton@h] okay well, since I haven't used much javascript, particularly with Ruby,
|   | 312902 [fophillips@f] =20
|   + 312882 [jcoglan@go g] ...
|   + 312889 [Kevin.Brown@] ...
|     312891 [a.etherton@h] and I don't even know what ssl is lol, I will go look into it.
|     312897 [davividal@si] A-m-a-z-i-n-g.
|     312899 [a.etherton@h] okay, so I know that I need to learn about SSL, but I don't think that's
|     312901 [james.britt@] If you are building a Rails app you would do better to ask your
+ 312885 [caduceass@gm] I haven't used Rails in a while, but what happens in between the form
  312890 [a.etherton@h] Thats what I'm not sure about/don't know how to do...I was hoping for
  + 312894 [a.etherton@h] but that I can do in Ruby instead of PHP
  | + 312895 [cdj@go -i c.] I wouldn't attempt to even do encryption in Javascript. You could, but there would be no point. Learn how to use SSL (should be easy, actually). Or Google for HTTPS; exact same thing, but may get you new pages.
  | + 312939 [Neuman.Vong@] If you want to save a MD5 hash of your password in the database, James has suggested
  + 312898 [davividal@si] You mean "md5"?

Treetop question
312892 [etaern@ya oo] grammar Tester

Having a difficult time with Case statements.
312906 [christopher.] I am trying to implement a simple frontend for a text adventure that
+ 312907 [paradisaeida] Add the method you created to the end of the program 'definition' you have.
| 312908 [christopher.] Thank you for the feedback but I should have mentioned that it is one of
+ 312909 [_mwryder@wo ] Looking at your code it looks like you need to remove the first case
  312910 [christopher.] Wrapped a call to startUp() into the main game loop and made startstate
  312913 [_mwryder@wo ] Glad to see you got it working.  I think what you were trying to do
  + 312914 [christopher.] Yeah I was expecting them to continue until told to quit! Is there a
  | 312916 [shevegen@li ] There probably are but my personal habit these days is to use two
  | 312938 [B.Candler@po] If you're going to keep state in a local variable, then you need to keep
  + 312956 [sepp2k@go gl] In C if there is no break it will fall through, yes, but that would hardly
    313055 [_mwryder@wo ] From the looks of the code that I was tracing selecting '2'  would set
    313056 [sepp2k@go gl] Yes, but selecting 1, sets the state to 4, so in that case he would not want
    313059 [christopher.] I'm not one hundred percent sure what either of you believe I wanted

HTML <form> and redirecting the result
312915 [shevegen@li ] since a long time I am using a very simple ruby script that translates
312917 [llleelay@gm ] ...

Help with Custom ERB Templates
312922 [eric@er cm c] I'm trying to create a custom erb template that allows me to mix MXML
312925 [eric@er cm c] Nevermind! http://builder.rubyforge.org/ seems to be a good base for

does ruby have an http proxy
312931 [etaern@ya oo] Is there an http proxy module that could be used ? For example , I would
+ 312932 [vjoel@pa h. ] Webrick does this nicely. See sample/webrick/httpproxy.rb in the ruby
+ 312935 [tpreal@gm il] require 'net/http'
  313021 [vjoel@pa h. ] Isn't that a client?

About mime/types
312933 [pal@pa be gs] Why does this MIME::Types['text/plain'] give 'text/plaintext/plain'?

generate uuid
312940 [hema@an le i] How Can I  generate uuid ? any references or Ideas could You people
+ 312949 [etaern@ya oo] Posted via http://www.ruby-forum.com/.
| 313404 [mo_mail@on h] In Windows, you can use this code.  I'm not sure where I found this
+ 313422 [ara.t.howard] a @ http://codeforpeople.com/
+ 313448 [phasis@gm il] require 'open-uri'
| 313586 [ezmobius@gm ] One thing I;ve found is that all of the UUID generators are painfully
| 313588 [james@gr yp ] uuid = `uuidgen`.strip
| + 313590 [tommy.nordgr] The variation I use is uuid = "x_#{`uuidgen`.strip}"
| + 313592 [ryand-ruby@z] that's nice. 10k real uuids in 1 minute is perfectly acceptable for
|   313595 [ara.t.howard] require 'open-uri'
+ 313678 [coder68@ya o] sudo gem install guid

Decode/encode Unicode
312941 [jonas.esp@go] How to decode  a String type to Unicode?
+ 312955 [tpreal@gm il] Unicode is not fully supported in Ruby 1.8.X, it will be in Ruby 1.9.
+ 312977 [james@gr yp ] $ ruby -KU -e 'p "R=E9sum=E9".unpack("U*")'
| 313044 [jonas.esp@go] Thanks! It will help until rb 1.9 been more extended.
+ 313030 [stephen.bois] This is a trickier question than you probably realize.

Re: DoS vulnerability in REXML
312942 [shugo.maeda@] I admit that my announcement is misleading.  It was based on the
+ 312943 [shugo.maeda@] There are some considerations to apply this fix to the Ruby's standard
| 313008 [gregory.t.br] Okay, I'll look out for that.  Thanks!
+ 313185 [shugo.maeda@] I have fixed the announcement.

dont def need return
312944 [sijo@ma xi n] I was learing Ruby and have code like
+ 312945 [codeblogger@] ...
+ 312946 [jgabrielygal] What happens is that Ruby returns the result of the last expression.
| 312947 [sijo@ma xi n] Thanks fr the reply
+ 312954 [wieczo.yo@go] If you want to return both arrays combine them in another array on the

Confused by scope in ruby
312948 [f.mischa@gm ] I've been writing in ruby for a bit, but ran into something while
+ 312951 [f.mischa@gm ] Posted via http://www.ruby-forum.com/.
+ 312952 [sepp2k@go gl] Well, that's exactly what's happening at C level - in both cases. The
| 313088 [f.mischa@gm ] Yes, that is helpful. Thank you both.
+ 312953 [tpreal@gm il] Assigning a value to a parameter simply assigns a new variable to the

[ANN] Mysqlplus, a new thread aware MySQL driver for Ruby
312959 [oldmoe@gm il] I am pleased to announce the availability of a new MySQL driver.

312960 [hema@an le i] How to download picture from the particular url ?
+ 312963 [etaern@ya oo] agent = WWW::Mechanize.new
| 312970 [hema@an le i] How about implementing using 'open uri'
| 312971 [etaern@ya oo] File.open("some_pic.jpg") do |file|
+ 313249 [tucano@re ip] require 'open-uri'
+ 313251 [tpreal@gm il] Posted via http://www.ruby-forum.com/.

How to format decimals on the fly (for EOF blocks)?
312964 [tefflox@gm i] required per day.  It's scaled in the db to 3 (or more) decimal places,
312973 [tefflox@gm i] sprintf !
312975 [B.Candler@po] I don't understand how your figures relate to each other in the example you

Per suite unit test setup and teardown
312967 [peter@se an ] I am putting some tests together that need to access an external service
+ 313246 [fox@ns l. su] Prior to all test executions.. you could put the setup at the outer
| 313250 [peter@se an ] Putting the global setup code outside the class does work but there is
| 314314 [pit.capitain] END {
| 314421 [r.grosmann@g] Why is a single END not enough? What is happening here?
+ 314338 [djberg96@gm ] gem install test-unit
  + 314356 [pit.capitain] Thank you for the hint, Daniel. I missed the new release.
  + 314423 [peter@se an ] Oh thanks for that. Will get downloading asap.

Sort an array based on an attribute of its objects
312968 [forum@jo h. ] The title of this topic is not very good, but I didn't really know how
+ 312972 [dblack@ru yp] array.group_by {|obj| obj.status }
| 312976 [robert.dober] David beat me to the line, but as somebody will post an inject based
+ 312978 [fxn@ha hr f.] If working with a Set is fine (there's #to_set) that's provided by Set#classify.

How would this Perl script look in Ruby?
312979 [avinash.maga] Can somebody please me tell the way to write this script in Ruby?
+ 312980 [nathan@na ha] Why don't you show us what you have, and where you are stuck, rather
| + 312981 [B.Candler@po] Certainly.
| + 312982 [avinash.maga] sorry about that.
|   312988 [shortcutter@] You can do
|   313077 [emmanuel.sur] ...
+ 313087 [monojohnny@g] <joke>
+ 313719 [w_a_x_man@ya] message_templates =
  313826 [w_a_x_man@ya] message_templates =

Small Doubt in Ruby
312983 [karoljouis@g] in C or C++. Please also give some links for that if possible. Thank you
+ 312984 [etaern@ya oo] Ruby supports inline C , and I guess you could call __asm__ from C ,
| 312985 [karoljouis@g] Thank you for you reply. But won't that reduce execution time of the
| 312986 [etaern@ya oo] I don't think it would be noticeable . Inline C is used in ruby ( among
| 312987 [karoljouis@g] Thank you.
+ 312997 [uzimonkey@gm] Assembly and Ruby are kind of an odd couple.  Compared to the cost of
  313150 [john.carter@] Usually inline asm is about doing Rich and Strange things to hardware.

specifying a network interface, with a http get request
312989 [ajp97@ca .a ] and am enjoying the diverse features it includes.
313071 [monojohnny@g] If you are using 'Mongrel' as your webserver (possibly this also works
313182 [ajp97@ca .a ] Hey John,
+ 313183 [etaern@ya oo] I'm no ruby expert , but I don't think that could be done from ruby .
| 313184 [ajp97@ca .a ] I'm about to dig into the ruby source code and see how much socket
| 313194 [antonin.aman] As your on the client side you do not bind you connect.
+ 313197 [monojohnny@g] Thanks for the clarification, but I still don't quite understand what
  313200 [ajp97@ca .a ] Antonin,
  + 313208 [monojohnny@g] If you use IP addresses (rather than a host), and those IP-addresses are
  | 313209 [ajp97@ca .a ] Its not running as a web request, the code for this is executed via the
  | 313217 [monojohnny@g] Sorry Andy , I'm lost to what you are asking here, I thought you were
  | 313219 [ajp97@ca .a ] Hey John, Yeah i've worked out the solution now using wget.
  + 313552 [jeremy@hi eg] If this is something that you are going to need to do for an extended

Beginner help: Problem installing sqlite3 on Windows XP
312990 [kasper@sl sh] I am new to Ruby, and i keep getting stuck in the same place getting
+ 312991 [etaern@ya oo] You could try installing nmake , and run it again . You can find nmake
| 312998 [kasper@sl sh] I tried to download nmake and placed NMAKE.EXE & NMAKE.ERR in the
+ 312994 [damnbigman@g] ...
| 312999 [kasper@sl sh] Sorry i am new to this. What do you mean by this? thanks for your help
| 313000 [damnbigman@g] ...
| 313034 [stephen.bois] This thread explains what is going on for you.  I use the mswin32
+ 313099 [jcarter@fr g] From what I can tell sqlite3-ruby VERSION 1.2.4 does not have an mswin32
  + 313103 [damnbigman@g] ...
  + 313181 [kasper@sl sh] Using version 1.2.3 fixed the problem. Thanks to all of your for trying
  + 313764 [johnts@ch rt] Anyone know when and/or if 1.2.4 will have a mswin32 gem built? Not

How can I require other module?
312992 [youhaodeyi@g] My ruby script and module script are in the same directory. I print the
+ 312995 [jcoglan@go g] ...
+ 312996 [roberto@RE O] Are you executing the script from the same directory?  Having "." in RUBY_PATH only means that your "current" directory will be checked, not the one actually hosting the script.
  313002 [youhaodeyi@g] Both of your code can solve my problem, thanks.

Hpricot query
313003 [markjturner@] I'm trying to parse an XML document (a google calendar feed), but I
+ 313005 [ant@se ia ta] hpricot isn't quite friendly with namespaces from what I have tried
| 313007 [markjturner@] familiar with xpath and I don't know how to find the tag I need with
| 313016 [ant@se ia ta] Actually google calander has a ruby plugin/api located here
| 313020 [markjturner@] alendar.rubyforge.org/plugins/doc/
+ 313045 [why@ru y- an] Your query is good.  I think it must be something else.
  + 313191 [markjturner@] le.com/public/full"
  + 325443 [yarnosh@gm i] Old thread brought to life...

Gems disapeared after port install of a package
313004 [t.bak@se le ] I am new to Mac, tried to set up MSSQL connection
313015 [frederick.ch] Have you ended up with two different installs of ruby (I imagine port
313053 [t.bak@se le ] Yes, indeed. gem is in /user/bin while irb is in /opt/local/bin/irb
313288 [t.bak@se le ] sudo port -uf uninstall ruby

to create MyDate class
313010 [citra_1235@h] im newly with this so i really need a help from u guys to slove my
313125 [citra_1235@h] Heres my question in this attachment
313129 [adam.shelly@] wow that doesnt look like homeworx at all.
313130 [citra_1235@h] Can you just give me a bit clue for this one, im so desperately

Request for feedback, suggestions, contributions.
313014 [kenneth.m.mc] I'm attempting to write a module whose classes will make it easier to

Order some files by time before display
313018 [dendicus@gm ] require 'find'
313023 [reitinge@in ] files = Dir[File.join('public/2008/', '**', @pattern)]
313024 [dendicus@gm ] Many thanks, Matthias! Your answer was perfectly resolve my problem and

Newb question: Printing a class.
313025 [ruby-forum@g] programmed before.  Im reading through this tutorial as my first venture
+ 313028 [shashank_hi@] This is because you are asking it to find the return value of method
| 313032 [ruby-forum@g] Thank you both that did work, but opened a new issue for me.
| 313040 [adam.shelly@] You are right, the Address class does have its own #to_s.  The issue
| 313043 [ruby-forum@g] Thank you, that worked great!
+ 313029 [reitinge@in ] There is no method called `person` in your Person class.  If you want to