[#163711] Re: [ANN] urirequire: I got yer Web 2.0 right here — "Daniel Sheppard" <daniels@...>

> if expected_digest

11 messages 2005/11/02

[#163730] ruby-dev summary 27393-27541 — Minero Aoki <aamine@...>

Hi all,

61 messages 2005/11/02
[#163734] Re: ruby-dev summary 27393-27541 — Christophe Grandsire <christophe.grandsire@...> 2005/11/02

Selon Minero Aoki <aamine@loveruby.net>:

[#163762] YACC (Was: Re: ruby-dev summary 27393-27541) — mental@... 2005/11/02

Quoting Christophe Grandsire <christophe.grandsire@free.fr>:

[#163736] Re: ruby-dev summary 27393-27541 — "David A. Black" <dblack@...> 2005/11/02

Hi --

[#163741] Re: ruby-dev summary 27393-27541 — nobuyoshi nakada <nobuyoshi.nakada@...> 2005/11/02

HI,

[#163818] Compiled version of Ruby — "zero" <web2ed@...>

I know this has been discussed before but I would like to know if

13 messages 2005/11/02

[#163865] Ruby On Rails Tutorials That Actually Work? — "Dale" <dmgreer@...>

This may not be the group to ask, if not pardon me. I've gone through three

10 messages 2005/11/03

[#163911] Ruby Certification — "Chintakrindi Meghanath" <Meghanath@...>

Hi

27 messages 2005/11/03

[#163955] Continous running thread — iamscottwalter@...

Hi,

16 messages 2005/11/03

[#164082] Some comments on new 1.9 features — "Trans" <transfire@...>

Just looking at http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9.

47 messages 2005/11/04
[#164217] Re: Some comments on new 1.9 features — "Domenico De Felice" <defelicedomenico@...> 2005/11/04

Nikolai Weibull wrote:

[#164104] i wanna get involved — Cam <cameron.matheson@...>

Hi,

13 messages 2005/11/04

[#164107] MS SQL Access from Ruby in Windows — Horacio Sanson <hsanson@...>

13 messages 2005/11/04

[#164187] Class and Mixin with same method name problem — petermichaux@...

Hi,

14 messages 2005/11/04

[#164195] Ruby making inroads at big corporation... small anecdote. — Stephen Waits <steve@...>

34 messages 2005/11/04
[#164239] Re: Ruby making inroads at big corporation... small anecdote. — James Britt <james_b@...> 2005/11/04

Stephen Waits wrote:

[#164420] can you recommend some easy ruby project for newbie? — nonocast <nonocast@...>

i am a ruby newbie

14 messages 2005/11/06

[#164450] what does --can't define singleton method-- mean? — Daniel Sche <uval@...>

RubyNG.hello /.*/

16 messages 2005/11/06

[#164456] Access control and class methods — Mads Kristensen <madsk@...>

Hi.

15 messages 2005/11/06

[#164472] rubyforge-0.0.0 — "Ara.T.Howard" <Ara.T.Howard@...>

12 messages 2005/11/06

[#164502] Lazy fun: Make unary minus silence stderr for backticks — Sam Stephenson <sstephenson@...>

I was reading about mentalguy's lazy.rb and thought it'd be fun to use

11 messages 2005/11/06

[#164529] programming best practices — swille <sillewille@...>

I have a couple of standard programming questions. The first is that

16 messages 2005/11/07

[#164658] Investigating Ruby - key limitations ? — "mortench" <mortench@...>

I have been looking at the Ruby programming language recently. I like

49 messages 2005/11/07
[#164794] Re: Investigating Ruby - key limitations ? — "mortench" <mortench@...> 2005/11/08

Thanks for all the replies. Since I can't possibly reply to all, I will

[#164728] which open source licence? — petermichaux@...

Hi,

20 messages 2005/11/08

[#164824] Checking for race conditions with Ruby threads — Wilson Bilkovich <wilsonb@...>

I've got an untrustworthy legacy app that seems to have a nasty race

11 messages 2005/11/08
[#164830] Re: Checking for race conditions with Ruby threads — mental@... 2005/11/08

Quoting Wilson Bilkovich <wilsonb@gmail.com>:

[#164881] Question about symbols — "Jacek Olszak" <jacekolszak@...2.pl>

Hi everyone...

15 messages 2005/11/08

[#164944] Equvialent of RoboCode and/or Terrarium for Ruby? — kheon@...

Just wondering if there is an equivalent to RoboCode (http://robocode.sourceforge.net/) or Terrarium (http://www.windowsforms.net/Applications/application.aspx?PageID=30&tabindex=8) currently available for Ruby.

9 messages 2005/11/09

[#164960] How to install something on MacOS X? — pete boardman <pete.boardman@...>

So far I've been learning Ruby (1.8.2 as pre-installed on Mac/Tiger)

13 messages 2005/11/09

[#164971] RUBY GRAMMAR — puellula@...

Hi!

31 messages 2005/11/09

[#165069] Red: The Ruby Journal, a professional periodical for Ruby developers — ruby.journal@...

I am pleased to pre-announce the launch of a new, professional

47 messages 2005/11/09
[#165094] Re: [ANN] Red: The Ruby Journal, a professional periodical for Ruby developers — Bill Guindon <agorilla@...> 2005/11/10

On 11/9/05, ruby.journal@mac.com <ruby.journal@mac.com> wrote:

[#165472] Re: [ANN] Red: The Ruby Journal, a professional periodical for Ruby developers — ruby.journal@... 2005/11/12

[#165473] Re: [ANN] Red: The Ruby Journal, a professional periodical for Ruby developers — Hal Fulton <hal9000@...> 2005/11/12

ruby.journal@mac.com wrote:

[#165162] Ruby - Newbie to Guru - Advice? — Sean Hussey <seanhussey@...>

Alright, I've been bitten by the Ruby bug, but I haven't yet had that

15 messages 2005/11/10

[#165218] Network computer name problem w/ Tiger and DRb — Jim Freeze <jim@...>

Hi

18 messages 2005/11/10
[#165220] Re: Network computer name problem w/ Tiger and DRb — Eric Hodel <drbrain@...7.net> 2005/11/10

On Nov 10, 2005, at 2:38 PM, Jim Freeze wrote:

[#165223] Re: Network computer name problem w/ Tiger and DRb — Jim Freeze <jim@...> 2005/11/10

On 11/10/05, Eric Hodel <drbrain@segment7.net> wrote:

[#165376] DocBook to PDF — Hal Fulton <hal9000@...>

I'm wanting to do some docbook to pdf conversion.

25 messages 2005/11/12

[#165379] Index and Query (#54) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

26 messages 2005/11/12
[#165777] Re: Index and Query (#54) — "Interfecus" <interfecus@...> 2005/11/14

Hi,

[#165787] Re: Index and Query (#54) — James Edward Gray II <james@...> 2005/11/15

On Nov 14, 2005, at 5:17 PM, Interfecus wrote:

[#165449] Converting between Time and DateTime — Lloyd Zusman <ljz@...>

What is the recommended method for converting between Time objects and

32 messages 2005/11/12
[#165450] Re: Converting between Time and DateTime — "David A. Black" <dblack@...> 2005/11/12

Hi --

[#165558] Re: Converting between Time and DateTime — Kirk Haines <khaines@...> 2005/11/13

On Saturday 12 November 2005 11:26 am, David A. Black wrote:

[#165726] Re: Converting between Time and DateTime — "Adam Sanderson" <netghost@...> 2005/11/14

Is there any reason to choose one over the other? At least for post

[#165595] Ruby Forum — Andreas Schwarz <f@...>

Hi,

56 messages 2005/11/13
[#165605] Re: [ANN] Ruby Forum — James Edward Gray II <james@...> 2005/11/14

On Nov 13, 2005, at 5:03 PM, Andreas Schwarz wrote:

[#165607] Re: Ruby Forum 2005/11/14

james wrote:

[#165614] Re: Ruby Forum — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/11/14

Toby DiPasquale wrote:

[#165597] Re: Equvialent of RoboCode and/or Terrarium for Ruby? — "Daniel Sheppard" <daniels@...>

17 messages 2005/11/13
[#165671] Re: Equvialent of RoboCode and/or Terrarium for Ruby? — "Dave Burt" <dave@...> 2005/11/14

Reyn Vlietstra mused:

[#165778] Re: Equvialent of RoboCode and/or Terrarium for Ruby? — "Kyle Heon" <kheon@...> 2005/11/14

Yes, and while this is basic in principle is really why it's such a great

[#165783] Re: Equvialent of RoboCode and/or Terrarium for Ruby? — Lyndon Samson <lyndon.samson@...> 2005/11/15

So, come on! Lets get a mailing list or some sort of forum set up to

[#165913] Re: Equvialent of RoboCode and/or Terrarium for Ruby? — "Adam Sanderson" <netghost@...> 2005/11/15

No way! Lets discuss the possibility of discussing this some more!

[#165656] Recursive functions — hans.sjunnesson@...

I know that this is a trivial problem, but I'm having a hard time

21 messages 2005/11/14

[#165755] removing a constant definition from an environment — Robert Evans <robert.evans@...>

Hi,

11 messages 2005/11/14
[#165757] Re: removing a constant definition from an environment — Ryan Leavengood <leavengood@...> 2005/11/14

On 11/14/05, Robert Evans <robert.evans@acm.org> wrote:

[#165760] Re: removing a constant definition from an environment — Robert Evans <robert.evans@...> 2005/11/14

Hi Ryan,

[#165764] Re: removing a constant definition from an environment — Mauricio Fern疣dez <mfp@...> 2005/11/14

On Tue, Nov 15, 2005 at 06:56:59AM +0900, Robert Evans wrote:

[#165935] DRb Crashing — James Edward Gray II <james@...>

If I launch this server:

18 messages 2005/11/15

[#166032] static variable; behaviour in ruby? — Hugh Sasse <hgs@...>

Any idea how to create or simulate a static variable in ruby?

15 messages 2005/11/16

[#166077] Proposed RCR: Object#replace — Austin Ziegler <halostatue@...>

On the Sydney list, Daniel Berger has been asking about a generic

24 messages 2005/11/16
[#166124] Re: Proposed RCR: Object#replace — Eric Mahurin <eric.mahurin@...> 2005/11/16

> class Object

[#166200] Keyword arguments like grandma makes 'em — "Trans" <transfire@...>

I'm messing around with some methods trying to figure out how to offer

14 messages 2005/11/17

[#166206] Time.yesterday ? :) — Marcin Jurczuk <mj-usunto@...>

Hello group.

16 messages 2005/11/17

[#166277] Ruby not commercial, right? — boscomonkey@...

I'm trying to organize a Ruby Meetup group in San Francisco

19 messages 2005/11/18
[#166300] Re: Ruby not commercial, right? — Mark Hubbart <discordantus@...> 2005/11/18

On 11/17/05, boscomonkey@gmail.com <boscomonkey@gmail.com> wrote:> I'm trying to organize a Ruby Meetup group in San Francisco> (http://ruby.meetup.com/6/) and applied to the SF Public Library to use> one of their small meeting rooms. They turned us down because they have> deemed Ruby to be a product for commercial gain. The analogy that the> SFPL contact person used is that one can walk into a bookstore and find> a book on Ruby; I countered that one can also find a book on> childrearing.>> The SFPL Meeting Room Community Use Rules (http://sfpl.org/libraryl> ocations/mtgrms/rules.htm) states [emphasis mine]:>> "No outside group or organization using a Library meeting room> shall: 1) charge an admission fee or solicit donations, 2) sell or> ***promote any material or service for private profit or gain***, 3)> engage in fund raising activities, (excepting those groups who have> contracted with the Library to do so in support of Library programs and> activities).">> I'm arguing that because Ruby is an Open Source project, there is no> private profit or gain when Ruby is utilized versus when another> programming language is utilized. As opposed to using Microsoft Excel> versus Lotus 1-2-3; in which case, Microsoft stands to make money from> Excel licenses.>> Can anyone think of better arguments? I think mine is a tad subtle for> non-computer people.

[#166452] web development w/ ruby — Cam <cameron.matheson@...>

Hi guys,

24 messages 2005/11/18
[#196269] Re: web development w/ ruby minus rails — rahul benegal <rahul_kumar@...> 2006/06/07

cameron.matheson wrote:

[#166457] Symbol#inspect bug? — "Dominik Bathon" <dbatml@...>

Hallo,

16 messages 2005/11/18
[#166495] Re: Symbol#inspect bug? — "Robert Klemme" <bob.news@...> 2005/11/19

Eric Mahurin <eric.mahurin@gmail.com> wrote:

[#166525] Re: Symbol#inspect bug? — Eric Mahurin <eric.mahurin@...> 2005/11/19

On 11/19/05, Robert Klemme <bob.news@gmx.net> wrote:

[#166532] Re: Symbol#inspect bug? — Mark Hubbart <discordantus@...> 2005/11/19

On 11/19/05, Eric Mahurin <eric.mahurin@gmail.com> wrote:> On 11/19/05, Robert Klemme <bob.news@gmx.net> wrote:> > > For many of the other core classes (and definitely all other immediate> > > classes), #inspect returns a representation that is eval'able to get> > > back an equivalent (or the same) object. When possible, I think that> > > is what #inspect should do. I think it is a bug that Symbol#inspect> > > almost does it, but not quite (quotes some cases but not others).> >> > Although I'd agree that Symbol#inspect can be improved and should be> > changend (as it's an easy fix) I have a different opinion about the usage of> > inspect in general: even inspect methods of core classes fail to return> > something that is proper ruby code.> >> > $ ruby -e 'p Object.new'> > #<Object:0x100f6b28>> > $ ruby -e 'a=[1];a<<a;p a'> > [1, [...]]>> I didn't say all core classes return something evalable for #inspect> (I said many). Here's the list I see:>> FalseClass, TrueClass, NilClass> Fixnum, Bignum> Float> String> Regexp> Symbol - close but no cigar> Class - kind of - it returns a constant for class that can be evaled> Array, Hash, Range - if no recursion and all elements have an evalable #inspect

[#166489] Best OS for Ruby Dev/Best OS for Ruby Hosting — "Rawn027" <Rawn027@...>

Which is the best OS to use for ruby development...My vote goes to Mac

22 messages 2005/11/19
[#166493] Re: Best OS for Ruby Dev/Best OS for Ruby Hosting — Mauricio Fern疣dez <mfp@...> 2005/11/19

On Sat, Nov 19, 2005 at 05:12:23PM +0900, Rawn027 wrote:

[#166498] Re: Best OS for Ruby Dev/Best OS for Ruby Hosting — Jacob Quinn Shenker <jqshenker@...> 2005/11/19

On 11/19/05, Mauricio Fern叩ndez <mfp@acm.org> wrote:> On Sat, Nov 19, 2005 at 05:12:23PM +0900, Rawn027 wrote:> > Which is the best OS to use for ruby development...My vote goes to Mac> > OS X?>> matz uses Debian ;-)

[#166505] Re: Best OS for Ruby Dev/Best OS for Ruby Hosting — Edwin van Leeuwen <edder@...> 2005/11/19

jqshenker wrote:

[#166745] Re: Best OS for Ruby Dev/Best OS for Ruby Hosting — Aaron Kulbe <akulbe@...> 2005/11/21

> Lots of people happen to like FreeBSD for its Ruby support. One of its> major system utilities, portupgrade, is written in Ruby, so that's one> neat aspect. I'd recommend staying away from Gentoo: I prefer> source-based OSs, but Gentoo just breaks too often for it to be worth> it. Also, Gentoo users are on the whole jerkyer and less helpful than> normal people.

[#166535] An alternative to Gems — "Trans" <transfire@...>

23 messages 2005/11/19
[#166557] Re: An alternative to Gems — Austin Ziegler <halostatue@...> 2005/11/19

On 11/19/05, Trans <transfire@gmail.com> wrote:

[#166625] Euchre Hands (#55) — Robin Stocker <robin@...>

Hi

29 messages 2005/11/20
[#166709] Re: [QUIZ SOLUTION] Euchre Hands (#55) — "Dominik Bathon" <dbatml@...> 2005/11/21

Here is my solution.

[#166714] Re: [QUIZ SOLUTION] Euchre Hands (#55) — "Dominik Bathon" <dbatml@...> 2005/11/21

Here is another solution to the problem. I got the idea for this while

[#166718] Re: [QUIZ SOLUTION] Euchre Hands (#55) — Zed Lopez <zed.lopez@...> 2005/11/21

On 11/20/05, Dominik Bathon <dbatml@gmx.de> wrote:

[#166729] Re: [QUIZ SOLUTION] Euchre Hands (#55) — "Dominik Bathon" <dbatml@...> 2005/11/21

On Mon, 21 Nov 2005 04:20:16 +0100, Zed Lopez <zed.lopez@gmail.com> wrote:

[#166733] Re: [QUIZ SOLUTION] Euchre Hands (#55) — Ryan Leavengood <leavengood@...> 2005/11/21

Thanks to inspiration from reading Zed Lopez's code, I've been able to

[#166651] Help requested: new book — "Mark Watson" <mark.watson@...>

I would appreciate some help defining the topics for a new free web

14 messages 2005/11/20

[#166706] Parsing excel CVS data on a mac OSX to extract blocks of cells — "anne001" <anne@...>

I would like to parse some excel CVS data which has a repetitive block

13 messages 2005/11/21

[#166720] Active Record without rails — Horacio Sanson <hsanson@...>

13 messages 2005/11/21

[#166759] url-monitoring script question — Torsten Schmidt <torstello@...>

Hi @all,

16 messages 2005/11/21

[#166796] fixrbconfig broken in 10.4.3 — "Rawn027" <Rawn027@...>

I get an error saying that ruby.h cannot be found please install dev

6 messages 2005/11/21
[#166980] Re: fixrbconfig broken in 10.4.3 — Michal Suchanek <hramrach@...> 2005/11/22

On 11/21/05, Rawn027 <Rawn027@gmail.com> wrote:> I get an error saying that ruby.h cannot be found please install dev> tools but i have dev tools installed and ruby.h is there when i use> locate. I have no idea how to fix this, did 10.4.3 fix the problems> previously there with 10.4's broken ruby? Can I compile my own and have> it work? Where can I go from here because I was told to use the ruby> howto on technoblog.

[#166984] Re: fixrbconfig broken in 10.4.3 — Dave Baldwin <dave.baldwin@3dlabs.com> 2005/11/22

[#166801] Regular Expressions and Ruby — George Lunsford <george.lunsford@...>

Hi, I'm new to the list and I hope this is the right place to ask the

17 messages 2005/11/21

[#166820] Trying to change my OS from Windows to Linux/Mac — "Sam Kong" <sam.s.kong@...>

Hello, Ruby people!

32 messages 2005/11/21

[#166897] How to upgrade to Ruby1.8-3? — Tony <nospam2@2nospam.com>

Hi, I already installed Ruby 1.8-2 but I'd like to upgrade to 1.8-3

11 messages 2005/11/22

[#167048] what is the ruby way to do this? — "ako..." <akonsu@...>

hello,

50 messages 2005/11/22
[#167050] Re: what is the ruby way to do this? — JB Eriksson <mrkode@...> 2005/11/22

On 11/22/05, ako... <akonsu@gmail.com> wrote:

[#167103] Re: what is the ruby way to do this? — Jeff Wood <jeff.darklight@...> 2005/11/23

I would do

[#167106] Re: what is the ruby way to do this? — "David A. Black" <dblack@...> 2005/11/23

Hi --

[#167051] How convert an integer to a bit array — Curt Hibbs <curt.hibbs@...>

Does anyone have a clever way to convert an integer to an array of bit

16 messages 2005/11/22

[#167089] String#to_rx ? — Alex Fenton <alex@...>

Possible RCR: would anyone else find this a useful addition to the core

35 messages 2005/11/22
[#167328] Re: String#to_rx ? — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/11/24

Alex Fenton wrote:

[#167549] Re: String#to_rx ? — Jeff Wood <jeff.darklight@...> 2005/11/26

I believe the Facets project already contains a method like this for String

[#167572] Re: String#to_rx ? — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/11/26

Jeff Wood wrote:

[#167625] Re: String#to_rx ? — "Trans" <transfire@...> 2005/11/26

nikolai,

[#167630] Re: String#to_rx ? — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/11/26

Trans wrote:

[#167632] Re: String#to_rx ? — Jeff Wood <jeff.darklight@...> 2005/11/27

How does this differ from embedding variables in regular expressions now with

[#167635] Re: String#to_rx ? — "Trans" <transfire@...> 2005/11/27

Jeff,

[#167638] Re: String#to_rx ? — Jeff Wood <jeff.darklight@...> 2005/11/27

I didn't want them to be ... I wanted the body of the string to be

[#167639] Re: String#to_rx ? — Jeff Wood <jeff.darklight@...> 2005/11/27

Although I am surprised there isn't a String#escape ( or maybe #escaped ) method

[#167651] Re: String#to_rx ? — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/11/27

Jeff Wood wrote:

[#167653] Re: String#to_rx ? — Jeff Wood <jeff.darklight@...> 2005/11/27

Yes I did read the original thread.

[#167656] Re: String#to_rx ? — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/11/27

Jeff Wood wrote:

[#167124] pattern: auto-running module init code — ptkwt@... (Phil Tomson)

13 messages 2005/11/23

[#167152] teaching ruby as cs intro? — Mike Schwab <michael.schwab@...>

My school teaches intro to programming with Java or C#, intro to cs

14 messages 2005/11/23

[#167184] Re: [BUG] string range membership — "Warren Brown" <warrenbrown@...>

Ara,

3 messages 2005/11/23
[#167200] Re: [BUG] string range membership — "Ara.T.Howard" <ara.t.howard@...> 2005/11/23

On Thu, 24 Nov 2005, Warren Brown wrote:

[#167219] Re: [BUG] string range membership — Mark Hubbart <discordantus@...> 2005/11/23

On 11/23/05, Ara.T.Howard <ara.t.howard@noaa.gov> wrote:> On Thu, 24 Nov 2005, Warren Brown wrote:>> >>> ruby -v -e "p(('1'..'10').to_a)"> >>> ruby 1.8.2 (2004-12-25) [i386-mswin32]> >>> ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]> >>>> >>> This shows a clear and unique mapping of the range> >>> '1'..'10' into a set of strings.> >>> >> but where do '01', '001', and '0001' go? they too,> >> are in the set of strings.> >> > You completely lost me there. '01' doesn't *go* anywhere. That> > string is not in the range '1'..'10', in the same way the 'x' is not in> > the range 'a'..'n'.>> says who? ;-) i may chose to define String#succ to do whatever i like -> including the values '01', '001', and '0001'.>> my point is simply that you seem to be merging the notion of ranges and sets.> the range abstract to_a is determined by only a few things>> - the start and end points>> - the succ method of the start value and each successive succ value> remember one could do this>> irb(main):003:0> class String; def succ; self == "1" ? 42 : super; end; end> => nil> irb(main):004:0> "1".succ> => 42>> - the spaceship operator for each succ value called against the endpoint>> because of this we cannot even safely call to_a on an arbitrary range., for instance>> irb(main):002:0> (42.0 .. 1.0).to_a> TypeError: can't iterate from Float> from (irb):2:in `each'> from (irb):2:in `to_a'> from (irb):2>>> in summary a range is nothing but a set of endpoints with some> abstract/duck-type-like methods that may or may not produce a set as a> __process__. note that the set produced is not part of the range itself and> can be dynamically altered or even be made to produce a different set each> time:>> harp:~ > cat a.rb> class Float> def succ> self + rand> end> end>> p((4.2 ... 42.0).to_a)>> harp:~ > ruby a.rb> [4.2, 4.60303889967309, 5.57983848378295, 6.19446672151043, 6.92731328072508, 7.40446684874589, 7.79202463038348, 8.67552806421286, 9.42821837951244, 10.1988047216007, 11.1116769865281, 11.6169205995556, 11.9975653524073, 12.2256247650959, 12.8874200335378, 13.1557666607712, 13.6470070004444, 14.2172959192607, 15.0882979655236, 15.3487930162798, 15.9791460692026, 16.4321713791994, 17.0903318945661, 17.2967949864209, 18.2400722395741, 18.7286500286255, 19.7174743954199, 20.4528553779707, 20.953553149678, 21.0415866875269, 21.2924876748544, 22.2378099442685, 23.0076932295775, 23.0941582708386, 23.4748092012559, 23.5515124737304, 24.3463511761819, 24.6901201768951, 25.2541406207396, 26.0256212044938, 26.843159468986, 26.9579528629072, 27.01297383827, 27.7250436963749, 27.9017308958297, 28.1100643283236, 28.4480522935525, 28.6197629801695, 29.3756706791326, 29.9897540116082, 30.0057580759777, 30.7085039121469, 30.7510332074171, 30.9096299847723, 30.9314941316772, 31.3964098461468, 31.7312966347497, 32.2153802510432, 32.619498970957, 32.9731525439908, 33.3765950052407, 34.3397676884718, 35.1641816525327, 35.4891756054474, 36.2408178073905, 36.8733362068042, 37.6251560883057, 37.8047618263845, 37.8828752584342, 38.2001976403303, 38.9255502197319, 39.8027872575378, 40.0416710479264, 40.9954826039753, 41.4534375661544]>>> > Don't let the fact that my example used strings that look like numbers> > confuse the issue. The issue is that a range of strings that can be> > converted into a finite set, has a method to test for membership in that> > range, that doesn't match values that are in the set. Wow, that sentence> > is even hard for *me* to follow.> >> > OK, let's take a different example to avoid all discussion of integers> > and various string representations of them.> >> >> ruby -v -e "p(('a'..'aa').to_a)"> > ruby 1.8.2 (2004-12-25) [i386-mswin32]> > ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",> > "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "aa"]> >> > Here we have a string range that has 27 "members". Now:>> not quite - we have a string range that __produces__ 27 elements. it does not> 'have' or 'contain' them. it merely suggests this set as it's current thought> on what that set might be. this set definition may change - unlike the> endpoints of the range - and it is therefore not a property of the range.>> >> ruby -e "p(('a'..'aa').member?('a'))"> > true> >> ruby -e "p(('a'..'aa').member?('b'))"> > false> > ...> >> ruby -e "p(('a'..'aa').member?('z'))"> > false> >> ruby -e "p(('a'..'aa').member?('aa'))"> > true> >> > Can this really be called correct behavior of the member?() method? I> > can't see any tenable argument to say that it is.>> the definition of membership may rely on endpoints only. that explains it> perfectly.>> harp:~ > irb> irb(main):001:0> 'z' < 'aa'> => false>> ergo - not in the set. the confustion here is caused by exactly the reasons> i'm explaining - String#succ has been defined not to create a monotonically> increasing (<=>) sequence - but to produce the "next" string in an english> sense. this is very useful for auto-generating names>> irb(main):004:0> "z99".succ> => "aa00">> if this were a monotonically increasing set the output would be>> => "z9:">> but that sure isn't that useful - unless you want to try to use ranges as> sets.>> the secret here is simply re-define String#succ - not Range#member. if> String#succ did a simply addition using base 255 arith you'd be set.

[#167194] Re: [BUG] string range membership — "Warren Brown" <warrenbrown@...>

Matz,

17 messages 2005/11/23

[#167295] Pickaxe tutorial section missing info on writing to files — Greg Gibson <greggib@...>

The Pickaxe seems to be missing an example (or two) about how to write a

12 messages 2005/11/24
[#167313] Re: Pickaxe tutorial section missing info on writing to files — Damphyr <damphyr@...> 2005/11/24

Greg Gibson wrote:

[#167325] RRobots - ducks, armed and dangerous — Simon Krer <SimonKroeger@...>

RRobots v0.1

38 messages 2005/11/24
[#167334] Re: RRobots - ducks, armed and dangerous — Edwin van Leeuwen <edder@...> 2005/11/24

SimonKroeger wrote:

[#167337] Re: RRobots - ducks, armed and dangerous — Simon Kröger <SimonKroeger@...> 2005/11/24

Edwin van Leeuwen wrote:

[#167356] Legal symbol names and generics — John Lam <drjflam@...>

I've just started thinking about generics in my Ruby <=3D> CLR bridge. This=

21 messages 2005/11/24
[#167362] Re: Legal symbol names and generics — Marcin Mielżyński <lopexx@...> 2005/11/24

it is legal (just use another symbol construction literal):

[#167396] Mac OS X TK — "James Edward Gray II" <james@...>

Is it possible to get a pure aqua TK running through Ruby on Mac OS X?

29 messages 2005/11/24
[#167486] Re: Mac OS X TK — Logan Capaldo <logancapaldo@...> 2005/11/25

On 11/24/05, James Edward Gray II <james@grayproductions.net> wrote:

[#167494] Re: Mac OS X TK — James Edward Gray II <james@...> 2005/11/25

On Nov 25, 2005, at 10:03 AM, Logan Capaldo wrote:

[#167500] Re: Mac OS X TK — Michal Suchanek <hramrach@...> 2005/11/25

On 11/25/05, James Edward Gray II <james@grayproductions.net> wrote:> On Nov 25, 2005, at 10:03 AM, Logan Capaldo wrote:>> > If you use the apple installed ruby its all of> > require 'tk' # Aqua GUI -- done>> If you have X11 installed. I have this working now. Thanks.>> > This may even work with a ruby installed from source, because I> > believe the> > magic is actually in the Tcl/Tk libs, not ruby.>> I can't get my custom compiled Ruby to do the same. I'm seeing:>> $ ruby -r tk -e1> /usr/local/lib/ruby/1.8/tk.rb:7:in `require': No such file to load --> tcltklib (LoadError)> from /usr/local/lib/ruby/1.8/tk.rb:7>> If anyone knows what I'm doing wrong there, please let me know.

[#167502] Re: Mac OS X TK — James Edward Gray II <james@...> 2005/11/25

On Nov 25, 2005, at 10:32 AM, Michal Suchanek wrote:

[#167562] Re: Mac OS X TK — Hidetoshi NAGAI <nagai@...> 2005/11/26

From: James Edward Gray II <james@grayproductions.net>

[#167563] Re: Mac OS X TK — James Edward Gray II <james@...> 2005/11/26

On Nov 25, 2005, at 9:23 PM, Hidetoshi NAGAI wrote:

[#167568] Re: Mac OS X TK — Hidetoshi NAGAI <nagai@...> 2005/11/26

From: James Edward Gray II <james@grayproductions.net>

[#167589] Re: Mac OS X TK — James Edward Gray II <james@...> 2005/11/26

On Nov 26, 2005, at 12:23 AM, Hidetoshi NAGAI wrote:

[#167593] Re: Mac OS X TK — Hidetoshi NAGAI <nagai@...> 2005/11/26

From: James Edward Gray II <james@grayproductions.net>

[#167601] Re: Mac OS X TK — James Edward Gray II <james@...> 2005/11/26

On Nov 26, 2005, at 10:40 AM, Hidetoshi NAGAI wrote:

[#167640] Re: Mac OS X TK — Hidetoshi NAGAI <nagai@...> 2005/11/27

From: James Edward Gray II <james@grayproductions.net>

[#167679] Re: Mac OS X TK — James Edward Gray II <james@...> 2005/11/27

On Nov 26, 2005, at 7:30 PM, Hidetoshi NAGAI wrote:

[#167453] Faster way to pick the every other array member? — Damphyr <damphyr@...>

we have [1,2,3,4,5,6,7] and want [2,4,6]

18 messages 2005/11/25

[#167465] `finalize' method? — Daniel Schierbeck <daniel.schierbeck@...>

Yeah, it's me again, your friendly neighbourhood power-suggester!

20 messages 2005/11/25
[#167468] Re: `finalize' method? — Jim Weirich <jim-keyword-rforum.c88827@...> 2005/11/25

dasch wrote:

[#167551] How do two objects communicate? — "anne001" <anne@...>

I wrote a small program the procedural way, now I would like to write

22 messages 2005/11/26

[#167585] Nubish questions about syntax and gems — "Ross Bamford" <rosco@...>

Hi folks.

13 messages 2005/11/26

[#167622] Turing 0.0.7 && cry for help — Michal <lists+rubytalk@...>

Hello all,

28 messages 2005/11/26
[#167709] Re: [ANN] Turing 0.0.7 && cry for help — Tobias Luetke <tobias.luetke@...> 2005/11/27

Great work on the library!

[#167735] Re: [ANN] Turing 0.0.7 && cry for help — Michal <lists+rubytalk@...> 2005/11/28

Hi,

[#167746] Re: [ANN] Turing 0.0.7 && cry for help — Hugh Sasse <hgs@...> 2005/11/28

On Mon, 28 Nov 2005, Michal wrote:

[#167780] Re: [BUG] string range membership — "Warren Brown" <warrenbrown@...>

Matz,

20 messages 2005/11/28
[#167782] Re: [BUG] string range membership — Yukihiro Matsumoto <matz@...> 2005/11/28

Hi,

[#167786] building ruby for speed: wise or otherwise? — Hugh Sasse <hgs@...>

My active record based script is taking longer than I'd like.

33 messages 2005/11/28
[#167790] Re: building ruby for speed: wise or otherwise? — Joel VanderWerf <vjoel@...> 2005/11/28

Hugh Sasse wrote:

[#167848] Wizard quiz — Leslie Viljoen <leslie@...>

I have written a few text adventures in TADS, the Texts

24 messages 2005/11/28
[#167884] Re: Wizard quiz — James Edward Gray II <james@...> 2005/11/28

On Nov 28, 2005, at 2:10 PM, Leslie Viljoen wrote:

[#167854] Programming Newbie: Ruby or Java? — "Dab" <dabhar1959@...>

Thanks for looking!

60 messages 2005/11/28
[#167861] Re: Programming Newbie: Ruby or Java? — Lyle Johnson <lyle.johnson@...> 2005/11/28

On 11/28/05, Dab <dabhar1959@hotmail.com> wrote:

[#167864] Re: Programming Newbie: Ruby or Java? — Christian Leskowsky <christian.leskowsky@...> 2005/11/28

I'm not sure why you guys think Ruby is easier than Java from a "Learn It"

[#167936] Re: Programming Newbie: Ruby or Java? — "Isaac Gouy" <igouy@...> 2005/11/29

mental@rydia.net wrote:

[#167982] Re: Programming Newbie: Ruby or Java? — mental@... 2005/11/29

Quoting Isaac Gouy <igouy@yahoo.com>:

[#167998] Re: Programming Newbie: Ruby or Java? — Peter Hickman <peter@...> 2005/11/29

mental@rydia.net wrote:

[#168001] Re: Programming Newbie: Ruby or Java? — mental@... 2005/11/29

Quoting Peter Hickman <peter@semantico.com>:

[#167869] what to do, what to do.. — Dirk Meijer <hawkman.gelooft@...>

hi everyone!

15 messages 2005/11/28

[#167888] GUI IDE for Ruby — tony <L@...>

Hi all,

40 messages 2005/11/29
[#167892] Re: GUI IDE for Ruby — Joe Van Dyk <joevandyk@...> 2005/11/29

On 11/28/05, tony <L@l.com> wrote:

[#168029] Splitting a text file into sentences — "basi" <basi_lio@...>

Looking for ideas on how to split a text file into sentences. I see the

38 messages 2005/11/29
[#168038] Re: Splitting a text file into sentences — Matthew Smillie <M.B.Smillie@...> 2005/11/30

[#168043] Re: Splitting a text file into sentences — "Kevin Olbrich" <kevin.olbrich@...> 2005/11/30

Depending on the text you might be able to search for a period (or other

[#168089] Re: Splitting a text file into sentences — Austin Ziegler <halostatue@...> 2005/11/30

On 11/29/05, Kevin Olbrich <kevin.olbrich@duke.edu> wrote:

[#168112] Re: Splitting a text file into sentences — Jeffrey Schwab <jeff@...> 2005/11/30

Austin Ziegler wrote:

[#168127] Re: Splitting a text file into sentences — Austin Ziegler <halostatue@...> 2005/11/30

On 11/30/05, Jeffrey Schwab <jeff@schwabcenter.com> wrote:

[#168137] Re: Splitting a text file into sentences — Jeffrey Schwab <jeff@...> 2005/11/30

Austin Ziegler wrote:

[#168142] Re: Splitting a text file into sentences — Austin Ziegler <halostatue@...> 2005/11/30

On 11/30/05, Jeffrey Schwab <jeff@schwabcenter.com> wrote:> Austin Ziegler wrote:>> Then, quite honestly, you were taught wrong. I was taught to use>> double spaces with a typewriter or when using fixed-pitch fonts>> (although that was later, since most computers and printers didn't>> have reliable kerning routines until I was out of university).>> Ultimately, the use of double spaces after a period is wrong *even>> with fixed-pitch fonts*, but it was done to be clearer since the>> width of the em-space and an en-space on a typewriter with a>> Courier-like font is exactly the same. The two spaces *simulates* an>> em-space in a typeset piece of work. (And that is *fact*, not>> opinion.)

[#168113] Ruby Enterprise App Design Advice — "TeslaOMD" <teslaomd@...>

I was wondering if anyone could give me some advice/thoughts/input

12 messages 2005/11/30

[#168144] Dumb question: in documentation, why Object#method, and not Object.method ? — "Elf M. Sternberg" <elf@...>

I keep seeing this syntax in documentation: Object#method, but in actual

17 messages 2005/11/30

[#168170] Help constructing interesting hash? — "Chris McMahon" <christopher.mcmahon@...>

Suppose I have an array of arrays like

12 messages 2005/11/30

[#168175] Ruby, MySQL on WinXP? — "planetthoughtful" <planetthoughtful@...>

Hello All,

13 messages 2005/11/30

[SUMMARY] TumbleDRYer (#53)

From: Ruby Quiz <james@...>
Date: 2005-11-03 13:44:29 UTC
List: ruby-talk #163910
Great quiz Hugh!  This is one of those unique ideas that was a lot of fun to
play with.  There's always some neat things to be accomplished with code that
writes code.

I want to take a look at Bob Showalter's solution below.  It's really just one
linear procedure, so I'll show all the code and then break it down:

	require 'strscan'
	require 'abbrev'
	
	class TumbleDRYer
	
	  # minimum length of a phrase to consider
	  MIN_PHRASE = 10
	
	  # minimum times a phrase must occur to consider
	  MIN_OCCUR = 3
	
	  # minimum length for abbreviation
	  MIN_ABBR = 2
	
	  def initialize(string)
	    @input = string
	  end
	
	  def dry
	
	    # this will accumulate a list of repeated phrases to condense
	    phrases = Array.new
	  
	    # this will receive the abbreviation for each phrase
	    abbr = Hash.new
	  
	    lines = @input.to_a
	    loop do
	  
	      # process the input data by lines. we find "phrases" by
	      # first finding the start and end of each "word" in the line,
	      # and then combining those words into longer phrases. for
	      # each phrase, we count the number of times it occurs in the
	      # total input.
	      phr = Hash.new
	      lines.each do |line|
	        s = StringScanner.new(line)
	        words = Array.new
	        loop do
	          s.scan_until(/(?=\S)/) or break
	          beg = s.pos
	          s.scan(/\S+/)
	          words << [ beg, s.pos ]
	        end
	    
	        # combine words to make 'phrases'
	        combos(words)
	    
	        # accumulate phrases, counting their occurences.
	        # skip phrases that are too short.
	        words.each do |from, to|
	          p = line[from, to - from]
	          next unless p.length >= MIN_PHRASE
	          phr[p] ||= 0
	          phr[p] += 1
	        end
	      end
	    
	      # get the longest phrase that occurs the most times
	      longest = phr.sort_by { |k,v| -(k.length * 1000 + v)
	        }.find { |k,v| v >= MIN_OCCUR } or break
	      phrase, occurs = longest
	    
	      # save the phrase, and then blank it out of the input data
	      # so we can search for more phrases
	      phrases << phrase
	      lines.each { |line| line.gsub!(phrase, ' ' * phrase.length) }
	    
	    end
	  
	    # now we have all the phrases we want to replace.
	    # find unique abbreviations for each phrase.
	    temp = Hash.new
	    phrases.each do |phrase|
	      key = phrase.scan(/\w+/).flatten.to_s.downcase
	      key = '_' + key unless key =~ /^[_a-zA-Z]/
	      key += '_' while temp.has_key? key
	      temp[key] = phrase
	    end
	    temp.keys.abbrev.sort.each do |s, key|
	      phrase = temp[key]
	      abbr[phrase] = s if abbr[phrase].nil? ||
	        abbr[phrase].length < MIN_ABBR
	    end
	  
	    # generate the output class
	    puts "class WashingMachine"
	    puts "  def initialize"
	    phrases.each do |phrase|
	      puts '    @' + abbr[phrase] + " = '" +
	        phrase.gsub("'", "\\\\'") + "'"
	      @input.gsub!(phrase, '#{@' + abbr[phrase] + '}')
	    end
	    puts "  end\n"
	    puts "  def output\nprint <<EOF"
	    puts @input
	    puts "EOF\n  end\n"
	    puts "end"
	  
	  end
	
	  private
	
	  def combos(arr, max = arr.size - 1, i = 0)
	    (i+1..max).each do |j|
	      arr << [ arr[i][0], arr[j][1] ]
	    end
	    combos(arr, max, i + 1) if i < max - 1
	  end
	
	end
	
	TumbleDRYer.new(ARGF.read).dry

That's the code, save one unused line I removed.

The first thing I do when reading code is to try and understand the process.  To
get the lay of the land, we need to know what's called where.  The path of
execution is trivial to find here.  The last line is the only code, besides a
couple of require statements, outside of a class definition.  We know that's
what Ruby will run.

That line tells us that we need to be examining two methods
TumbleDRYer#initialize and TumbleDRYer#dry.  Don't be shy with that scrollbar
now.  Zip around until you find them.  TumbleDRYer#initialize is easy enough,
all it does is record the passed input.  TumbleDRYer#dry is a monster, so let's
come back to it.

Anything else in this file?  Well, we can see that two standard libraries are
used, strscan and abbrev.  We can also see three constants at the top of the
class that start to give us ideas about how the code will break down the
sections it is meant to simplify.

Beyond that, there's only one other method, which we can assume is a helper to
TumbleDRYer#dry.  It's smaller, so let's see if we can figure it out first.  Uh
oh, recursion!  My brain just melted and leaked out of my ear.  Okay, let's see
if we can cheat and just call it.  Copy and paste and irb to the rescue:

	>> def combos(arr, max = arr.size - 1, i = 0)
	>>   (i+1..max).each do |j|
	?>     arr << [ arr[i][0], arr[j][1] ]
	>>   end
	>>   combos(arr, max, i + 1) if i < max - 1
	>> end
	=> nil
	>> combos( (1..10).to_a )
	=> nil

Or not.  I was hoping for a more informative return value obviously.

Okay, it looks like I actually need to read a little.  I see that `arr` is a
parameter of the method.  That's how I decided on a sample data set.  A little
farther in I can see `arr << ...`.  Bingo.  It modifies the array.  Now I know
how to check it:

	>> test_data = (1..10).to_a
	=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
	>> combos test_data
	=> nil
	>> test_data
	=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, [1, 1], [1, 1], [1, 0], [1, 0], [1, 1],
	[1, 1], [1, 0], [1, 0], [1, 1], [0, 1], [0, 0], [0, 0], [0, 1], [0, 1],
	[0, 0], [0, 0], [0, 1], [1, 0], [1, 0], [1, 1], [1, 1], [1, 0], [1, 0],
	[1, 1], [0, 0], [0, 1], [0, 1], [0, 0], [0, 0], [0, 1], [1, 1], [1, 1],
	[1, 0], [1, 0], [1, 1], [0, 1], [0, 0], [0, 0], [0, 1], [1, 0], [1, 0],
	[1, 1], [0, 0], [0, 1], [1, 1]]

Yuck.  In the dictionary under "unhelpful", you will find the above listing. 
More reading is required.

Well, if I finish the line I stopped at last time, I find this little nugget: 
`[ arr[i][0], arr[j][1] ]`.  That makes me think `arr` is expected to be an
Array of Arrays.  It looks like the subarrays only need two items, since the
indexes are 0 and 1.  Third try is a charm:

	>> test_data = [1, 3, 5, 7, 9].map { |n| [n, n + 1] }
	=> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
	>> combos test_data
	=> nil
	>> test_data
	=> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 4], [1, 6], [1, 8], [1, 10],
	[3, 6], [3, 8], [3, 10], [5, 8], [5, 10], [7, 10]]

That looks promising.  Now what are we seeing?  Obviously it added some
groupings to the end of the Array.  1 was already seen with 2, but it also
paired it with 4, 6, 8, and 10.  That's all of the other second elements.  Then
3 is paired with 6, 8, and 10 and it was already paired with 4, which leaves
only 2 missing.  Now I see the pattern.  Each first element is paired with all
of the second elements that come after it, in the original Array.

Even knowing how that works, I'm not sure I understand what that is actually for
yet.  I'll file it away in the back of my mind and see if I'm ready to tackle
TumbleDRYer#dry.

Here's the first chunk of that method, to save you some scrolling:

	def dry
	
	  # this will accumulate a list of repeated phrases to condense
	  phrases = Array.new
	
	  # this will receive the abbreviation for each phrase
	  abbr = Hash.new
	
	  lines = @input.to_a
	  loop do
	
	    # process the input data by lines. we find "phrases" by
	    # first finding the start and end of each "word" in the line,
	    # and then combining those words into longer phrases. for
	    # each phrase, we count the number of times it occurs in the
	    # total input.
	    phr = Hash.new
	    lines.each do |line|
	      s = StringScanner.new(line)
	      words = Array.new
	      loop do
	        s.scan_until(/(?=\S)/) or break
	        beg = s.pos
	        s.scan(/\S+/)
	        words << [ beg, s.pos ]
	      end
	  
	      # combine words to make 'phrases'
	      combos(words)
	  
	      # accumulate phrases, counting their occurrences.
	      # skip phrases that are too short.
	      words.each do |from, to|
	        p = line[from, to - from]
	        next unless p.length >= MIN_PHRASE
	        phr[p] ||= 0
	        phr[p] += 1
	      end
	    end
	    
	    # get the longest phrase that occurs the most times
	    longest = phr.sort_by { |k,v| -(k.length * 1000 + v)
	      }.find { |k,v| v >= MIN_OCCUR } or break
	    phrase, occurs = longest
	    
	    # save the phrase, and then blank it out of the input data
	    # so we can search for more phrases
	    phrases << phrase
	    lines.each { |line| line.gsub!(phrase, ' ' * phrase.length) }
	    
	  end
	  
	  # ...

Luckily, that's well commented code.  The comments easily explain what the
variables are for, and then we get an introduction to the process in `loop do
... end`.  As soon as I read that, TumbleDRYer#combos clicks into place.

The Array of Arrays passed to TumbleDRYer#combos holds a start and end position
for each word.  The start positions are combined with all of the end positions
after that word to give the possible phrases.

Before the call to TumbleDRYer#combos, we can see the Array of Arrays being
created, with a little StringScanner work.  Words are found by scanning
non-whitespace characters, because replacing at any other boundaries pretty much
kills the human readable goal of the output.

Just beneath that call to TumbleDRYer#combos the phrases are assembled, checked
for the minimum length, and tallied in the phrase count.  The chunk of code
right after that selects the longest phrase that occurs the most times for
substitution.  Note the clever use of negation in #sort_by here, to reverse the
order.  The last couple of lines save the phrase and replace it with whitespace,
so it won't match in future iterations.

Remember, this is all inside of a big `loop do ... end`, so by the time we break
out of here, all the replacement phrases will have been selected.

	  # ...
	  
	  # now we have all the phrases we want to replace.
	  # find unique abbreviations for each phrase.
	  temp = Hash.new
	  phrases.each do |phrase|
	    key = phrase.scan(/\w+/).flatten.to_s.downcase
	    key = '_' + key unless key =~ /^[_a-zA-Z]/
	    key += '_' while temp.has_key? key
	    temp[key] = phrase
	  end
	  temp.keys.abbrev.sort.each do |s, key|
	    phrase = temp[key]
	    abbr[phrase] = s if abbr[phrase].nil? ||
	      abbr[phrase].length < MIN_ABBR
	  end
	
	  # ...

This section of the method just finds names for each of the replaced phrases. 
It generally choses the first few letters or numbers of the phrase, unless it
needs to insert a _ character or two to maintain Ruby syntax or break
ambiguities.  A lot of the work here is done by the abbrev library.  If you're
not familiar with how that works, ask irb:

	>> require "abbrev"
	=> true
	>> names = %w{James Edward Gray II}
	=> ["James", "Edward", "Gray", "II"]
	>> names.respond_to? :abbrev
	=> true
	>> names.abbrev
	=> {"II"=>"II", "Gr"=>"Gray", "Gra"=>"Gray", "Jam"=>"James", "Ja"=>"James",
	"Edw"=>"Edward", "Edwa"=>"Edward", "Edwar"=>"Edward", "Gray"=>"Gray",
	"James"=>"James", "Edward"=>"Edward", "E"=>"Edward", "G"=>"Gray",
	"Jame"=>"James", "I"=>"II", "Ed"=>"Edward", "J"=>"James"}

It turns an Array into a Hash of all the unique abbreviations that can be used
to form the words in the original Array.

Last little bit of code:

	  # ...
	  
	  # generate the output class
	  puts "class WashingMachine"
	  puts "  def initialize"
	  phrases.each do |phrase|
	    puts '    @' + abbr[phrase] + " = '" +
	      phrase.gsub("'", "\\\\'") + "'"
	    @input.gsub!(phrase, '#{@' + abbr[phrase] + '}')
	  end
	  puts "  end\n"
	  puts "  def output\nprint <<EOF"
	  puts @input
	  puts "EOF\n  end\n"
	  puts "end"
	  
	end

That just outputs the DRYed code to STDOUT.  This output uses a Ruby heredoc
with String interpolation.  Unfortunately, I think that means that Ruby code,
with its own String interpolation, will confuse it.  Have a look at Dominik
Bathon's code for custom interpolation or Daniel Sheppard's code for ERb
templates that even make use of arguments in replacement.

As always my thanks to all the creative souls that gave this quiz a try.  All of
the solutions are educational.

Ruby Quiz will take a week off now so I can run up to Denver and wish my sister,
Nicole Blake Thanner, a happy sweet sixteenth birthday!

In This Thread

Prev Next