[#267026] attr_reader — 7stud 7stud <dolgun@...>

On p. 30-31 of "Programming Ruby (2nd ed)", there is this example:

15 messages 2007/09/01

[#267065] Seeing the source — Michel Cabili <michel.cabili@...>

Hello. I'm new to Ruby (and also to scripting languages).

38 messages 2007/09/01

[#267086] Help with leap year programing — HB <hbqian@...>

Hi, All,

19 messages 2007/09/01

[#267106] Singleton Modules rather than Singleton Classes — Trans <transfire@...>

This recently came up in the thread entitled "Python-style

14 messages 2007/09/01

[#267113] Parsing query parameters from hyperlink — "lrlebron@..." <lrlebron@...>

I am trying to parse strings like this

11 messages 2007/09/01
[#267128] Re: Parsing query parameters from hyperlink — Robert Klemme <shortcutter@...> 2007/09/01

On 01.09.2007 19:34, lrlebron@gmail.com wrote:

[#267184] How does ruby handle overloading? — pongba <pongba@...>

Matz once replied on Cedric's blog that

13 messages 2007/09/02

[#267261] subject line — "Devi Web Development" <devi.webmaster@...>

I don't know who would make this sort of decision, but could we put

103 messages 2007/09/02
[#267397] Re: subject line — Trans <transfire@...> 2007/09/03

[#267633] Re: subject line — Chad Perrin <perrin@...> 2007/09/04

On Tue, Sep 04, 2007 at 04:01:56AM +0900, Trans wrote:

[#267655] Re: subject line — Trans <transfire@...> 2007/09/04

[#267656] Re: subject line — Chad Perrin <perrin@...> 2007/09/04

On Wed, Sep 05, 2007 at 08:54:22AM +0900, Trans wrote:

[#267665] Re: subject line — "Rimantas Liubertas" <rimantas@...> 2007/09/05

> Any time you tell someone to completely change the tools (s)he uses,

[#267744] Re: subject line — Chad Perrin <perrin@...> 2007/09/05

On Wed, Sep 05, 2007 at 10:12:53AM +0900, Rimantas Liubertas wrote:

[#267266] Re: subject line — Dan Zwell <dzwell@...> 2007/09/02

Devi Web Development wrote:

[#267481] Re: subject line — Bil Kleb <Bil.Kleb@...> 2007/09/04

Chad Perrin wrote:

[#267506] Re: subject line — John Joyce <dangerwillrobinsondanger@...> 2007/09/04

Respectfully, no, unless it's very short. I suggest sort by the To:

[#267510] Re: subject line — "Robert Klemme" <shortcutter@...> 2007/09/04

I vote against, basically because I believe the issue can be solved

[#267514] Re: subject line — "Peter Cooper" <peter@...> 2007/09/04

I vote against. Those with the firehose of ruby-talk gushing into their

[#267282] assigning to hash keys when there is a default value? — 7stud -- <dolgun@...>

Can someone explain why there is a difference in the second line of

41 messages 2007/09/03
[#267283] Re: assigning to hash keys when there is a default value? — dblack@... 2007/09/03

Hi --

[#267286] Re: assigning to hash keys when there is a default value? — 7stud -- <dolgun@...> 2007/09/03

unknown wrote:

[#267310] Re: assigning to hash keys when there is a default value? — Peña, Botp <botp@...> 2007/09/03

From: 7stud -- [mailto:dolgun@excite.com]

[#267330] Re: assigning to hash keys when there is a default value? — 7stud -- <dolgun@...> 2007/09/03

Pe単a, Botp wrote:

[#267335] Re: assigning to hash keys when there is a default value? — "Russell Norris" <rsl@...> 2007/09/03

I don't think this is a bug, kittens. since h[2] returns a value [eventhough it's not set], it causes h[2] to evaluate so the assignmentnever happens. x ||= y just means give me x or set x to y if there'sno value for x. h[2] _does_ have a value if only a default one.

[#267338] Re: assigning to hash keys when there is a default value? — dblack@... 2007/09/03

Hi --

[#267344] Re: assigning to hash keys when there is a default value? — "Russell Norris" <rsl@...> 2007/09/03

I learned that x ||= y means set x to y unless x, so I don't see the

[#267431] Re: assigning to hash keys when there is a default value? — Peña, Botp <botp@...> 2007/09/04

From: sconds@gmail.com [mailto:sconds@gmail.com] On Behalf Of Russell Norris:

[#267511] Re: assigning to hash keys when there is a default value? — "Robert Klemme" <shortcutter@...> 2007/09/04

2007/9/4, Pe, Botp <botp@delmonte-phil.com>:

[#267325] Re: assigning to hash keys when there is a default value? — "Robert Klemme" <shortcutter@...> 2007/09/03

2007/9/3, dblack@wobblini.net <dblack@wobblini.net>:

[#267318] Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...>

Hi guys,

32 messages 2007/09/03
[#267326] Re: Filling individual cells in a grid — "Todd Benson" <caduceass@...> 2007/09/03

On 9/3/07, Joop Van den tillaart <tillaart36@hotmail.com> wrote:

[#267329] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

> With your current code...

[#267341] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

Is there no one else who can help me out a bit?

[#267348] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/03

On Sep 3, 2007, at 8:40 AM, Joop Van den tillaart wrote:

[#267363] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

Wow, thanks for your help...

[#267868] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/06

Joop Van den tillaart wrote:

[#267885] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 7:44 AM, Joop Van den tillaart wrote:

[#267899] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/06

hi thanks for your help,

[#267964] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 11:38 AM, Joop Van den tillaart wrote:

[#267984] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 4:47 PM, Morton Goldberg wrote:

[#268074] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/07

Morton Goldberg wrote:

[#268630] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/11

Hi guys,

[#268645] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

[#268647] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/11

Morton Goldberg wrote:

[#268677] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 7:57 AM, Joop Van den tillaart wrote:

[#268695] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 2:03 PM, Morton Goldberg wrote:

[#268705] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 4:34 PM, Morton Goldberg wrote:

[#267357] with — Matthias Wächter <matthias@...>

Sorry folks if this was raised already, but google is not very

14 messages 2007/09/03

[#267370] wierd floating point output — Matthias Wächter <matthias@...>

Folks,

14 messages 2007/09/03
[#267371] Re: wierd floating point output — dblack@... 2007/09/03

Hi --

[#267373] Re: wierd floating point output — Matthias Wächter <matthias@...> 2007/09/03

On 03.09.2007 19:51, dblack@wobblini.net wrote:

[#267433] Programming Ruby For Newbies — Jin Dynasty <jin.the.miner@...>

Howdy there,

25 messages 2007/09/04

[#267457] Ruby is much slower on linux when compiled with --enable-pthread? — "Adam Kramer" <akramer@...>

Hi,

18 messages 2007/09/04

[#267469] Best IDE for ruby and rails development — AJay Maurya <amaurya@...>

36 messages 2007/09/04
[#267471] Re: Best IDE for ruby and rails development — "Thomas Preymesser" <thopre@...> 2007/09/04

On 04/09/07, AJay Maurya <amaurya@brickred.com> wrote:

[#267476] Re: Best IDE for ruby and rails development — Arthur Murauskas <arthur.murauskas@...> 2007/09/04

On Tuesday 04 September 2007 10:31:23 AJay Maurya wrote:

[#267569] running ruby — yahdoco <yahdoco@...>

Hi Everyone...I am a very new ruby user. I have downloaded ruby to my

28 messages 2007/09/04
[#267574] Re: running ruby — Konrad Meyer <konrad@...> 2007/09/04

On Tuesday 04 September 2007 11:20:05 am yahdoco wrote:

[#267594] Re: running ruby — yahdoco <yahdoco@...> 2007/09/04

I sill have the same two problems:

[#267573] Embedded vs. Non-embedded Tests — Trans <transfire@...>

As far as I know, Facets is the only large project that uses embedded

14 messages 2007/09/04
[#267579] Re: Embedded vs. Non-embedded Tests — "Rick DeNatale" <rick.denatale@...> 2007/09/04

On 9/4/07, Trans <transfire@gmail.com> wrote:

[#267723] Multiple Assignments: Newbie question — "Z T" <zoater@...>

When I run my program:

15 messages 2007/09/05

[#267783] before, after and around Ruby 1.9 — Trans <transfire@...>

Any chance Ruby 1.9 will have before, after and around method

40 messages 2007/09/05
[#267816] Re: before, after and around Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/05

Hi,

[#267825] Re: before, after and around Ruby 1.9 — Joel VanderWerf <vjoel@...> 2007/09/06

Yukihiro Matsumoto wrote:

[#267797] question on bottleneck of ruby — Roger Pack <rogerpack2005@...>

Question: if I made the statement "Ruby is slower than some other

26 messages 2007/09/05
[#267807] Re: question on bottleneck of ruby — khaines@... 2007/09/05

On Thu, 6 Sep 2007, Roger Pack wrote:

[#271288] Re: question on bottleneck of ruby — Roger Pack <rogerpack2005@...> 2007/09/27

Thanks Kirk.

[#271298] Re: question on bottleneck of ruby — "Francis Cianfrocca" <garbagecat10@...> 2007/09/27

On 9/27/07, Roger Pack <rogerpack2005@gmail.com> wrote:

[#267857] Symbols and frozen strings — Brian Candler <B.Candler@...>

I just had a thought.

13 messages 2007/09/06

[#267871] Count and Say (#138) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

21 messages 2007/09/06

[#267941] Is this a bug or a feature? — Martin Jansson <martialis@...>

irb(main):002:0> i=1

13 messages 2007/09/06

[#268006] help me condence my code? — "Simon Schuster" <significants@...>

I know this could be more idiomatic to ruby.

23 messages 2007/09/07

[#268052] read a specific line from a file — Bulhac Mihai <mihai.bulhac@...>

how can i read only a line from a txt file?

18 messages 2007/09/07

[#268108] Netbeans, Eclipse and ruby! How to...? — "André Cardoso" <thyandrecardoso@...>

well, i should start to say that i'm pretty new to ruby!!

15 messages 2007/09/07

[#268307] Bug in lambda? — kevin cline <kevin.cline@...>

This looks like a pretty serious bug. It seems that lambda-

36 messages 2007/09/09
[#268323] Re: Bug in lambda? — dblack@... 2007/09/09

Hi --

[#268485] Re: Bug in lambda? — "Robert Klemme" <shortcutter@...> 2007/09/10

2007/9/9, dblack@wobblini.net <dblack@wobblini.net>:

[#268316] module_function :func vs. MyModule.func? — 7stud -- <dolgun@...>

The following produce the same output:

16 messages 2007/09/09

[#268362] Hash — Ron Green <rongreen1@...>

What is the purpose of string hash? What would you use it for?

21 messages 2007/09/09

[#268403] What Linux distribution to choose for learning Ruby and Ruby on Rails — "Slavo Furman" <slavof@...>

Hi!

82 messages 2007/09/09
[#268413] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/09

-----BEGIN PGP SIGNED MESSAGE-----

[#268418] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Slavo Furman" <slavof@...> 2007/09/09

Thanks for all answers... :)

[#268425] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268427] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Reid Thompson <reid.thompson@...> 2007/09/10

M. Edward (Ed) Borasky wrote:

[#268439] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268444] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Reid Thompson <reid.thompson@...> 2007/09/10

M. Edward (Ed) Borasky wrote:

[#268451] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268545] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Ezra Zygmuntowicz <ezmobius@...> 2007/09/10

Hi~

[#268595] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/11

-----BEGIN PGP SIGNED MESSAGE-----

[#268606] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/11

On Tue, Sep 11, 2007 at 12:00:57PM +0900, M. Edward (Ed) Borasky wrote:

[#268611] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/11

-----BEGIN PGP SIGNED MESSAGE-----

[#268614] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — bob@... (Bob Proulx) 2007/09/11

M. Edward (Ed) Borasky wrote:

[#268405] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Marcin Raczkowski <mailing.mr@...> 2007/09/09

Slavo Furman wrote:

[#268750] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — hemant <gethemant@...> 2007/09/12

On 9/10/07, Marcin Raczkowski <mailing.mr@gmail.com> wrote:

[#269173] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Shot (Piotr Szotkowski)" <shot@...> 2007/09/15

hemant:

[#269182] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Todd Benson" <caduceass@...> 2007/09/15

On 9/15/07, Shot (Piotr Szotkowski) <shot@hot.pl> wrote:

[#269199] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/15

Todd Benson wrote:

[#268433] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Trans <transfire@...> 2007/09/10

[#268436] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268447] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Trans <transfire@...> 2007/09/10

[#268513] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Mon, Sep 10, 2007 at 12:07:42PM +0900, Trans wrote:

[#268517] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Lionel Bouton <lionel-subscription@...> 2007/09/10

Chad Perrin wrote the following on 10.09.2007 18:46 :

[#268539] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 01:54:42AM +0900, Lionel Bouton wrote:

[#268557] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Lionel Bouton <lionel-subscription@...> 2007/09/10

Thanks for the answer, that was an interesting reading. I've some

[#268565] Re: [OT] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 05:38:32AM +0900, Lionel Bouton wrote:

[#268570] Re: [OT] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 07:00:50AM +0900, Chad Perrin wrote:

[#268658] undefined method `+' for nil:NilClass (NoMeth — Mahen Surinam <neoanderson12@...>

Dear All,

14 messages 2007/09/11

[#268663] Camping or Merb — "Eduardo Tongson" <propolice@...>

Hi folks,

19 messages 2007/09/11

[#268672] Graphics... why so shrouded in mystery? — Weston Campbell <silvershockwave@...>

I've been working with ruby for quite a while now, and I still don't

13 messages 2007/09/11

[#268761] what is this syntax: \001\002 ? — 7stud -- <dolgun@...>

Hi,

15 messages 2007/09/12

[#268786] copy/paste line numbers with code — Max Williams <toastkid.williams@...>

I'm writing up my project report and want to include line numbers with

12 messages 2007/09/12

[#268802] IronRuby — Lloyd Linklater <lloyd@2live4.com>

I have heard disturbing things about IronRuby. The short version is

36 messages 2007/09/12
[#268828] Re: IronRuby — Greg Donald <greg@...> 2007/09/12

On Thu, 13 Sep 2007, Lloyd Linklater wrote:

[#268833] Re: IronRuby — "Felix Windt" <fwmailinglists@...> 2007/09/12

> -----Original Message-----

[#268911] Re: IronRuby — Charles Oliver Nutter <charles.nutter@...> 2007/09/13

Bill Kelly wrote:

[#268918] Debug — "coolgeng coolgeng" <coolgeng410@...>

With the Rails, I build a project connecting the MySQL. But When I change

17 messages 2007/09/13

[#268970] Cross-platform Home Directory? — Trans <transfire@...>

I have a little app that needs to store session data. I assume the

19 messages 2007/09/13

[#269047] IP to Country (#139) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

32 messages 2007/09/14

[#269063] How many computers in the house? — Todd Burch <promos@...>

I went to the Lone Star Ruby Conference last week. 7 of us went out to

41 messages 2007/09/14

[#269125] Unicode — Zephyr Pellerin <ztz@...>

I hate to discuss something related to the development timeline, I know

26 messages 2007/09/15
[#270180] Re: Unicode — "Michal Suchanek" <hramrach@...> 2007/09/21

On 15/09/2007, Zephyr Pellerin <ztz@nxvr.org> wrote:

[#269140] one line to print the statement AS WELL AS the evaluated value like in C — kendear <summercoolness@...>

i wonder in Ruby, is there a line method to do something like in C

11 messages 2007/09/15

[#269214] Newbie help — Ali Koubeissi <ali.koubeissi@...>

Hey, I've started with Ruby two days ago, and I have some questions.

19 messages 2007/09/16

[#269251] Ruby Forum > Ruby Talk > comp.lang.ruby ? — Kenneth LL <kenneth.kin.lum@...>

so it seems like Google created Ruby Talk and anything posted to Ruby

25 messages 2007/09/16

[#269315] Newbie: what's Ruby idiom for word-by-word input? — Alex Shulgin <alex.shulgin@...>

Hi,

16 messages 2007/09/16
[#269326] Re: Newbie: what's Ruby idiom for word-by-word input? — Robert Klemme <shortcutter@...> 2007/09/16

On 16.09.2007 21:08, Alex Shulgin wrote:

[#269407] Re: Newbie: what's Ruby idiom for word-by-word input? — Alex Shulgin <alex.shulgin@...> 2007/09/17

On Sep 17, 12:19 am, Robert Klemme <shortcut...@googlemail.com> wrote:

[#269441] Re: Newbie: what's Ruby idiom for word-by-word input? — William James <w_a_x_man@...> 2007/09/17

On Sep 17, 4:30 am, Alex Shulgin <alex.shul...@gmail.com> wrote:

[#269357] Tk Ruby / Fx Ruby / Wx Ruby — "Jayson Williams" <williams.jayson@...>

I have looked at these three GUI's for Ruby, and would like to know

12 messages 2007/09/17

[#269440] group array elements in groups of two — Emmanuel Oga <oga_emmanuel_oga@...>

A better way to do this? :

13 messages 2007/09/17

[#269450] how to use tuple as hash key — SpringFlowers AutumnMoon <summercoolness@...>

in Python, a hash key cannot be [1,2,3] but must be (1,2,3), a tuple.

13 messages 2007/09/17
[#269453] Re: how to use tuple as hash key — Stefano Crocco <stefano.crocco@...> 2007/09/17

Alle luned狸 17 settembre 2007, SpringFlowers AutumnMoon ha scritto:

[#269562] The meaning of a = b in object oriented languages — Summercool <Summercoolness@...>

30 messages 2007/09/18

[#269596] finding string matches, in order, in a file — Peter Bailey <pbailey@...>

Hi,

19 messages 2007/09/18
[#269601] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

[#269605] Re: finding string matches, in order, in a file — Peter Bailey <pbailey@...> 2007/09/18

William James wrote:

[#269627] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

On Sep 18, 8:28 am, Peter Bailey <pbai...@bna.com> wrote:

[#269631] Re: finding string matches, in order, in a file — Peter Bailey <pbailey@...> 2007/09/18

William James wrote:

[#269637] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

On Sep 18, 10:27 am, Peter Bailey <pbai...@bna.com> wrote:

[#269616] CPU Usage not near 100% when running code — SpringFlowers AutumnMoon <summercoolness@...>

I tested some computation intensive Ruby code. When running, the CPU

11 messages 2007/09/18

[#269732] How to print FULL stacktrace of exception w/ line #? — Andrew Chen <meihome@...>

The ruby interpreter prints out a full trace of the exception.

12 messages 2007/09/19

[#269779] how can I remove all the comments in my c program. — Vellingiri Arul <hariharan.spc@...>

Dear Friends,

25 messages 2007/09/19

[#269813] YAML & readlines & modify text files — Dan George <endege@...>

Hello,

16 messages 2007/09/19
[#269834] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269879] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 5:27 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269888] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269910] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 9:22 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269913] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269925] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 11:03 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269816] How to compute Sunrise / Sunset ? — Joe Joe <joepetrini@...>

I need to compute sunrise/set times in ruby for a given long lat. Does

12 messages 2007/09/19

[#269862] special Array method about Unix pathes — unbewusst.sein@... (Une B騅ue)

15 messages 2007/09/19

[#269873] scraping web pages for cisco products — Chuck Dawit <chuckdawit@...>

16 messages 2007/09/19

[#269902] Do C Extensions Block Ruby? — "Wayne E. Seguin" <wayneeseguin@...>

Does a C extension running in a ruby-thread block all ruby threads

16 messages 2007/09/19
[#269904] Re: Do C Extensions Block Ruby? — Nobuyoshi Nakada <nobu@...> 2007/09/19

Hi,

[#269924] Re: Do C Extensions Block Ruby? — Joel VanderWerf <vjoel@...> 2007/09/19

Nobuyoshi Nakada wrote:

[#269971] Is there any separate editor for ruby? — Vellingiri Arul <hariharan.spc@...>

Hai Friends,

13 messages 2007/09/20

[#270018] Idiomatic Ruby for Array#extract / Range#length? — "Sammy Larbi" <sam@...>

During the monthly meeting of our code dojo, we were surprised by a couple

27 messages 2007/09/20
[#270039] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 2:28 PM, Sammy Larbi wrote:

[#270047] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Xavier Noria <fxn@hashref.com> wrote:

[#270051] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 5:39 PM, Rick DeNatale wrote:

[#270056] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Xavier Noria <fxn@hashref.com> wrote:

[#270065] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#270084] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 7:26 PM, Rick DeNatale wrote:

[#270110] I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Ruby Maniac <raychorn@...>

I am new to Ruby and I could use some expert advice as to how I can

62 messages 2007/09/20
[#270145] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Brian Adkins <lojicdotcom@...> 2007/09/21

On Sep 20, 6:02 pm, Ruby Maniac <raych...@hotmail.com> wrote:

[#270149] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — John Joyce <dangerwillrobinsondanger@...> 2007/09/21

[#270236] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Ruby Maniac <raychorn@...> 2007/09/21

On Sep 20, 7:16 pm, John Joyce <dangerwillrobinsondan...@gmail.com>

[#270239] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Todd Benson" <caduceass@...> 2007/09/21

On 9/21/07, Ruby Maniac <raychorn@hotmail.com> wrote:

[#270305] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Nobuyoshi Nakada" <nobu@...> 2007/09/22

Hi,

[#270575] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Ilmari Heikkinen" <ilmari.heikkinen@...> 2007/09/24

On 9/22/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:

[#270115] How fast does your Ruby run? — SpringFlowers AutumnMoon <summercoolness@...>

How fast does your Ruby run?

114 messages 2007/09/20
[#270118] Re: How fast does your Ruby run? — Todd Burch <promos@...> 2007/09/20

SpringFlowers AutumnMoon wrote:

[#270167] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/09/21

Todd Burch wrote:

[#270168] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/09/21

Charles Oliver Nutter wrote:

[#270182] Re: How fast does your Ruby run? — gga <GGarramuno@...> 2007/09/21

Seems like a pretty silly test, but okay...

[#270468] Re: How fast does your Ruby run? — David Orriss Jr <codethought@...> 2007/09/23

SpringFlowers AutumnMoon wrote:

[#276142] Re: How fast does your Ruby run? — Daniel Schömer <daniel.schoemer@...> 2007/10/27

Gentoo Linux on Intel Pentium 4 2.40GHz (512 KB cache):

[#276152] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/10/27

Daniel Scher wrote:

[#276153] Re: How fast does your Ruby run? — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/27

Charles Oliver Nutter wrote:

[#276191] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/10/27

M. Edward (Ed) Borasky wrote:

[#270161] Re: [ANN] Metadata 1.0-rc2 — Peña, Botp <botp@...>

From: Ilmari Heikkinen [mailto:ilmari.heikkinen@gmail.com]

6 messages 2007/09/21

[#270245] CplusRuby - Gluing C and Ruby — Michael Neumann <mneumann@...>

Hi all,

22 messages 2007/09/21

[#270320] sequel problem: no such file to load -- mysql (LoadError) — Michael Andreasen <ventosus@...>

Hi, i tried to learn about sequel (and Ruby) and got this problem

10 messages 2007/09/22

[#270377] Getting started with Ruby (noob confusion) — Nunya Business <sasnso4a5w12kb8@...>

Hi everyone!

16 messages 2007/09/22

[#270451] Recent Criticism about Ruby (Scalability, etc.) — "forrie@..." <forrie@...>

I presume most people here read today's article on Slashdot which had

80 messages 2007/09/23
[#270729] Re: Recent Criticism about Ruby (Scalability, etc.) — "Phlip" <phlip2005@...> 2007/09/25

> I presume most people here read today's article on Slashdot

[#270760] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/09/25

On Tue, Sep 25, 2007 at 01:04:21PM +0900, Phlip wrote:

[#270789] Re: Recent Criticism about Ruby (Scalability, etc.) — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 1:15 am, Chad Perrin <per...@apotheon.com> wrote:

[#271162] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/09/26

On Tue, Sep 25, 2007 at 10:40:04PM +0900, Ruby Maniac wrote:

[#272380] Re: Recent Criticism about Ruby (Scalability, etc.) — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Chad Perrin wrote:

[#272394] Re: Recent Criticism about Ruby (Scalability, etc.) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

Charles Oliver Nutter wrote:

[#272398] Re: Recent Criticism about Ruby (Scalability, etc.) — benjohn@... 2007/10/03

[#272405] Re: Recent Criticism about Ruby (Scalability, etc.) — MenTaLguY <mental@...> 2007/10/03

On Thu, 4 Oct 2007 00:19:40 +0900, benjohn@fysh.org wrote:

[#272412] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/10/03

On Thu, Oct 04, 2007 at 12:38:25AM +0900, MenTaLguY wrote:

[#272426] Re: Recent Criticism about Ruby (Scalability, etc.) — MenTaLguY <mental@...> 2007/10/03

On Thu, 4 Oct 2007 01:42:22 +0900, Chad Perrin <perrin@apotheon.com> wrote:

[#272439] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/10/03

On Thu, Oct 04, 2007 at 02:39:28AM +0900, MenTaLguY wrote:

[#270924] Re: Recent Criticism about Ruby (Scalability, etc.) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/26

Chad Perrin wrote:

[#270482] how to use Ruby / Tk to display a text message status box — SpringFlowers AutumnMoon <summercoolness@...>

how can we pop up a Tk window to display the temporary results of a

17 messages 2007/09/23
[#270980] Re: how to use Ruby / Tk to display a text message status box — Summercool <Summercoolness@...> 2007/09/26

[#270508] This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Ruby Maniac <raychorn@...>

I welcome any corrections anyone might be able to make since I am new

60 messages 2007/09/24
[#270524] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Phrogz <phrogz@...> 2007/09/24

On Sep 23, 8:50 pm, Ruby Maniac <raych...@hotmail.com> wrote:

[#270531] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — John Joyce <dangerwillrobinsondanger@...> 2007/09/24

Why do people troll?

[#270535] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Mohit Sindhwani <mo_mail@...> 2007/09/24

John Joyce wrote:

[#270557] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — benjohn@... 2007/09/24

> John Joyce wrote:

[#270597] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Chad Perrin <perrin@...> 2007/09/24

On Mon, Sep 24, 2007 at 06:34:57PM +0900, benjohn@fysh.org wrote:

[#270599] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/24

Chad Perrin wrote:

[#270727] Re: This is why Ruby 1.8.6 can never be made to run anywhere — 7stud -- <dolgun@...> 2007/09/25

Bill Kelly wrote:

[#270532] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "Michael T. Richter" <ttmrichter@...> 2007/09/24

Can I ask why *ANYBODY* took a message by someone calling themselves

[#270536] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/24

Michael T. Richter wrote:

[#270542] "myscript.rb " - there's a blank in my name! — Todd Burch <promos@...>

On a Mac - Tiger 10.4.10.

13 messages 2007/09/24

[#270596] best way to 'hide' a method when method_missing is in town — "Kevin Barnes" <vinbarnes@...>

I am trying to hide a method in a subclass whose base class has

11 messages 2007/09/24

[#270663] Favorite idiom for "keep doing this until it returns nil/false" — Phrogz <phrogz@...>

I want to keep running gsub! on a string until it returns nil. How do

12 messages 2007/09/24

[#270708] object_id 1, 2, 3 — SpringFlowers AutumnMoon <summercoolness@...>

Fixnum object_id

15 messages 2007/09/25

[#270788] I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...>

I love Ruby but what is the deal with the lack of a VM ?

25 messages 2007/09/25
[#270791] Re: I love Ruby but what is the deal with... this ! — Gregory Seidman <gsslist+ruby@...> 2007/09/25

On Tue, Sep 25, 2007 at 10:35:06PM +0900, Ruby Maniac wrote:

[#270794] Re: I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 6:52 am, Gregory Seidman <gsslist+r...@anthropohedron.net>

[#270815] Re: I love Ruby but what is the deal with... this ! — "Walter Purvis" <wpmailinglists@...> 2007/09/25

Troll.

[#270867] Re: I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 8:23 am, "Walter Purvis" <wpmailingli...@gmail.com> wrote:

[#270872] Re: I love Ruby but what is the deal with... this ! — Phlip <phlip2005@...> 2007/09/25

> Do you classify all those who have an opposing viewpoint as being a

[#270792] Ruby Scales just fine ! — Ruby Maniac <rubymaniac@...>

Just buy a bunch of Quad Core Opterons and get over it !

24 messages 2007/09/25
[#270800] Re: Ruby Scales just fine ! — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/25

Ruby Maniac wrote:

[#270842] Re: Ruby Scales just fine ! — Eric Hodel <drbrain@...7.net> 2007/09/25

On Sep 25, 2007, at 07:22 , M. Edward (Ed) Borasky wrote:

[#270813] Why dynamic languages for ActiveRecord..? — ypomonh <ypomonh@...>

I having problems understanding why people prefer to implement the

14 messages 2007/09/25

[#270888] The guy who wrote RubyScript2Exe needs to seriously reconsider how this little "gem" works... — Ruby Maniac <rubymaniac@...>

I have a very simple Ruby script that does nothing more than compute

13 messages 2007/09/25

[#270916] ruby regex on html file — eggie5 <eggie5@...>

I'm trying to write a rake task to extract all the script tags out of

12 messages 2007/09/25

[#270966] Feature request for RubyScript2Exe — Ruby Maniac <rubymaniac@...>

It would be nice if RubyScript2Exe was able to handle a passworded ZIP

11 messages 2007/09/26

[#270989] Detecting number ranges — Jay Levitt <jay+news@...>

I had to write a script this evening to take an unsorted input file of the

17 messages 2007/09/26

[#271046] Finding the last Sunday of a month — Peter Bailey <pbailey@...>

Hello,

31 messages 2007/09/26
[#271050] Re: Finding the last Sunday of a month — Yossef Mendelssohn <ymendel@...> 2007/09/26

On Sep 26, 8:44 am, Peter Bailey <pbai...@bna.com> wrote:

[#271078] Recursing through directories — Gabriel Dragffy <gabe@...>

Hi there

14 messages 2007/09/26

[#271089] OneClickInstaller/RubyGems problems — Trans <transfire@...>

Is there anything you have to do after installing the Windows

16 messages 2007/09/26

[#271143] Confession: I never learned CS — Jay Levitt <jay+news@...>

I was thinking about my "Detecting number ranges" question and the various

24 messages 2007/09/26
[#271317] Re: Confession: I never learned CS — Jay Levitt <jay+news@...> 2007/09/27

On Thu, 27 Sep 2007 23:57:08 +0900, Ilmari Heikkinen wrote:

[#271147] Syntax for <stringVariable>.new ? — Larry Fast <lfast@...>

Hi Rubyists and ...istas,

14 messages 2007/09/26
[#271148] Re: Syntax for <stringVariable>.new ? — Sebastian Hungerecker <sepp2k@...> 2007/09/26

Larry Fast wrote:

[#271212] Confession: I never did ASM — julik <listbox@...>

I would love to join the recently started confession fest.

57 messages 2007/09/27
[#271220] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/27

julik wrote:

[#271279] Re: [OT] Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/27

[#271393] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/28

John Joyce wrote:

[#271403] Re: [OT] Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/28

[#271412] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/28

John Joyce wrote:

[#271672] Re: Confession: I never did ASM — Brian Adkins <lojicdotcom@...> 2007/09/29

On Sep 27, 1:21 am, julik <list...@julik.nl> wrote:

[#271695] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/29

[#272303] Re: Confession: I never did ASM — Brian Adkins <lojicdotcom@...> 2007/10/03

On Sep 29, 3:27 pm, John Joyce <dangerwillrobinsondan...@gmail.com>

[#272307] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/10/03

[#272309] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

John Joyce wrote:

[#272322] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/10/03

[#272325] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

John Joyce wrote:

[#272423] Re: Confession: I never did ASM — Chad Perrin <perrin@...> 2007/10/03

On Wed, Oct 03, 2007 at 02:08:02PM +0900, M. Edward (Ed) Borasky wrote:

[#272508] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/04

Chad Perrin wrote:

[#271356] is there to invoke 'previous' in Find? (or refresh the current path?) — "dtown22@..." <dtown22@...>

I am writing a small script which recursively goes down a dir

10 messages 2007/09/27

[#271360] mac - hpricot problems — Sergio Ruiz <sergio@...>

i am trying to get hpricot running (so i can run mechanize) and am

24 messages 2007/09/27
[#271368] Re: mac - hpricot problems — Daniel Waite <rabbitblue@...> 2007/09/27

Sergio Ruiz wrote:

[#271370] Re: mac - hpricot problems — Sergio Ruiz <sergio@...> 2007/09/28

[#271376] Re: mac - hpricot problems — Ryan Davis <ryand-ruby@...> 2007/09/28

[#271364] Re: Anyone interested In IronRuby — Phrogz <phrogz@...>

On Sep 26, 11:47 pm, IronRuby <rubyguja...@gmail.com> wrote:

12 messages 2007/09/27

[#271394] dike-0.0.1 - a memory leak detector — "ara.t.howard" <ara.t.howard@...>

19 messages 2007/09/28
[#271522] Re: [ANN] dike-0.0.1 - a memory leak detector — Joel VanderWerf <vjoel@...> 2007/09/28

ara.t.howard wrote:

[#271526] Re: [ANN] dike-0.0.1 - a memory leak detector — "ara.t.howard" <ara.t.howard@...> 2007/09/28

[#271467] Probable Iterations (#141) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

15 messages 2007/09/28

[#271472] Windows - Get current logged user — Rodrigo Bermejo <rodrigo.bermejo@...>

14 messages 2007/09/28

[#271499] a different type of reference (shocked) — SpringFlowers AutumnMoon <summercoolness@...>

Before, when I say Ruby's reference to an object

14 messages 2007/09/28

[#271617] how can I start a shell process and return immediately? — Stephen Bannasch <stephen.bannasch@...>

I want to start a Java program from a Ruby program and have the Java

16 messages 2007/09/29
[#341070] Re: how can I start a shell process and return immediately? — Enling Li <enling.li@...> 2009/07/09

I have another quetion related to fire off a back ground shell process

[#271649] Is there a combination of a struct and an array? I wanna iterate over all created objects from a certain struct-class (I guess). — kazaam <kazaam@...>

I have a file with many entries and much of these I don't need. Let's imagine:

8 messages 2007/09/29

[#271673] a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...>

when we say

57 messages 2007/09/29
[#271677] Re: a = Dog.new # a is not a pointer and not a reference? — Morton Goldberg <m_goldberg@...> 2007/09/29

On Sep 29, 2007, at 1:16 PM, SpringFlowers AutumnMoon wrote:

[#271698] Re: a = Dog.new # a is not a pointer and not a reference? — "Austin Ziegler" <halostatue@...> 2007/09/29

On 9/29/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:

[#271718] Re: a = Dog.new # a is not a pointer and not a reference? — Joel VanderWerf <vjoel@...> 2007/09/29

Austin Ziegler wrote:

[#271804] Re: a = Dog.new # a is not a pointer and not a reference? — "Austin Ziegler" <halostatue@...> 2007/09/30

On 9/29/07, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:

[#271732] Re: a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...> 2007/09/30

Austin Ziegler wrote:

[#271734] Re: a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...> 2007/09/30

SpringFlowers AutumnMoon wrote:

[#271740] Re: a = Dog.new # a is not a pointer and not a reference? — Morton Goldberg <m_goldberg@...> 2007/09/30

On Sep 29, 2007, at 8:18 PM, SpringFlowers AutumnMoon wrote:

[#271738] Newbie needs help getting user input — Peter Vanderhaden <bostonantifan@...>

I'm trying to learn Ruby and trying to convert a Perl program at the

14 messages 2007/09/30

[#271776] Can you please help to make decision? — Byung-Hee HWANG <bh@...>

Fist of all, sorry for poor English, I am not professional English

34 messages 2007/09/30
[#271808] Re: Can you please help to make decision? — 7stud -- <dolgun@...> 2007/09/30

I would choose python.

[#271784] which language allows you to change an argument's value? — Summercool <Summercoolness@...>

34 messages 2007/09/30

[SUMMARY] Twisting a Rope (#137)

From: Ruby Quiz <james@...>
Date: 2007-09-06 11:59:32 UTC
List: ruby-talk #267870
The discussion for this quiz was very interesting.  It's probably worth your
time to go back and read those messages, if you haven't already.  Some points I
got out of the discussion were:

	* It's tricky to get ropes right.  Clever implementations may loose key
	  rope qualities, like the O(1) concatenation time.
	* The functional approach, building immutable ropes, is probably
	  superior considering how ropes are intended to be used.
	* Autorebalancing didn't hurt much, at least in the quiz test case.
	* Copy-On-Write is helpful, when it works.

Many of these points came out due to Eric Mahurin's work in benchmarking the
submitted solutions.  Eric also submitted several variations of rope classes, a
few of which I want to take a look at below.  Let's begin with the class Eric
uses to build the rope trees:

	module Mahurin
	  class Rope
	    include Enumerable
	    # form a binary tree from two ropes (possibly sub-trees)
	    def initialize(left,right)
	      @left = left
	      @right = right
	      @llength = @left.length
	      @length = @llength+@right.length
	      @depth = [left.depth, right.depth].max+1
	    end
	    # number of elements in this rope
	    def length
	      @length
	    end
	    # depth of the tree (to help keep the tree balanced)
	    def depth
	      @depth
	    end
	    # left rope (not needed when depth==0)
	    def left
	      @left
	    end
	    # right rope (not needed when depth==0)
	    def right
	      @right
	    end
	    
	    # ...

Here we see the setup and relevant attributes of Rope objects.  First we have
the fact that they are binary trees, with left and right subtrees.  Next we see
that Eric is going to track two lengths for Rope objects, both the total length
and the length of just the left subtree.  The reasoning for that will become
apparent when we examine indexing.  Finally, Eric tracks a depth, for use in
rebalancing.

There are really two major operations that are key to a Rope implementation: 
concatenation and indexing.  Here's the concatenation side of the puzzle:

	    # ...
	
	    # appended rope (non-modifying)
	    def +(other)
	      # balance as an AVL tree
	      balance = other.depth-@depth
	      if balance>+1
	        left = other.left
	        right = other.right
	        if left.depth>right.depth
	          # rotate other to right before rotating self+other to left
	          (self + left.left) + (left.right + right)
	        else
	          # rotate self+other to left
	          (self + left) + right
	        end
	      elsif balance<-1
	        if @right.depth>@left.depth
	          # rotate self to left before rotating self+other to right
	          (@left + @right.left) + (@right.right + other)
	        else
	          # rotate self+other to right
	          @left + (@right + other)
	        end
	      else
	        self.class.new(self, other)
	      end
	    end
	    alias_method(:<<, :+)
	
	    # ...

This method is only this long because it automatically rebalances the tree as
needed.  In fact, if you glance down to the final else clause, you will see the
trivial implementation, which is just to construct a new Rope from the current
Rope and the concatenated element.

The rebalancing done here is, as the comment suggests, a textbook AVL
implementation.  With an AVL tree, you subtract the left depth from the right
depth to get a tree's balance factor.  Anything in the range of -1 to 1 is a
balanced tree.  If the factor is outside of that range, one or two rotations are
required to rebalance the tree.

I'm not going to go into the specific rotations.  If you would like to read up
on them, I recommend:

	http://fortheloot.com/public/AVLTreeTutorial.rtf

Let's move on to the indexing methods used to pull information back out of a
Rope:

	  # ...
	  
	  # slice of the rope
	  def slice(start, len)
	    return self if start.zero? and len==@length
	    rstart = start-@llength
	    return @right.slice(rstart, len) if rstart>=0
	    llen = @llength-start
	    rlen = len-llen
	    if rlen>0
	      @left.slice(start, llen) + @right.slice(0, rlen)
	    else
	      @left.slice(start, len)
	    end
	  end
	  # element at a certain position in the rope
	  def at(index)
	    rindex = index-@llength
	    if rindex<0
	      @left.at(index)
	    else
	      @right.at(rindex)
	    end
	  end
	  
	  # ...

Have a look at the at() method first, because it's easier to digest and it shows
the concept of indexing this tree structure.  Essentially, to index in the tree
you check a position against the left length.  If it's less than, index the left
side.  If it's greater than, index the right.  This search tactic is the
hallmark attribute of binary trees.

The slice() method works the same way.  It's just more complicated because it
has to work with two indices instead of one.  Finding the start index is the
same strategy we saw in at().  If that index is in the right subtree, the end
will be as well and the code makes the recursive hand-off without further
checks.  When it's in the left, the end must be located.  If that end point
turns out to also be in the left, the hand-off is made to the left side.  When
it is in the right, a partial slice() is made from both halves and combined. 
This covers all the cases.

Eric added a couple more methods to the Rope class that cover iteration and
converting to a String:

	    # ...
	    
	    # iterate through the elements in the rope
	    def each(&block)
	      @left.each(&block)
	      @right.each(&block)
	    end
	    # flatten the rope into a string (optionally starting with a prefix)
	    def to_s(s="")
	      @right.to_s(@left.to_s(s))
	    end
	  end
	  
	  # ...

That covers the tree implementation.  What we haven't seen yet though, are the
leaf nodes.  We need two types for the implementation I want to examine,
EmptyRope and StringRope.  Here's the first of those:

	  # ...
	  
	  EmptyRope = Object.new
	  class << EmptyRope
	    include Enumerable
	    def length
	      0
	    end
	    def depth
	      0
	    end
	    def +(other)
	      other
	    end
	    alias_method(:<<, :+)
	    def slice(start, len)
	      self
	    end
	    def each
	    end
	    def to_s
	      ""
	    end
	  end
	  
	  # ...

This implementation is kind of a poor man's singleton instance (the design
pattern, not the Ruby concept, though we see both here).  There shouldn't be any
surprises in this code.  The attributes are zeroed, concatenation results in
whatever the concatenated element is, and slice()ing just returns self which
doubles as an empty String.

That leaves just one last leaf, StringRope:

	  # ...
	  
	  class StringRope
	    include Enumerable
	    def self.new(*args)
	      if args.empty?
	        EmptyRope
	      else
	        super
	      end
	    end
	    def initialize(data)
	      @data = data
	    end
	    def length
	      @data.length
	    end
	    def depth
	      0
	    end
	    
	    # ...

This class just wraps a String to support the Rope API we've been examining. 
About the only interesting trick here is the is that the default new() for this
class is overridden to allow returning an EmptyRope as needed.  Anytime the
argument is provided though, this method does hand-off to the default new()
implementation.

Here's the concatenation method:

	  # ...
	  
	  def +(other)
	    balance = other.depth
	    if balance>1
	      left = other.left
	      right = other.right
	      if left.depth>right.depth
	        # rotate other to right before rotating self+other to left
	        (self + left.left) + (left.right + right)
	      else
	        # rotate self+other to left
	        (self + left) + right
	      end
	    else
	      Rope.new(self, other)
	    end
	  end
	  alias_method(:<<, :+)
	  
	  # ...

We see some more balance work here, but the algorithm is simplified since only
the right side can be a subtree.  Beyond that, we've seen this code before.

Here are the final few methods:

	    # ..
	    
	    def slice(start, len)
	      return self if start.zero? and len==@data.length
	      # depend on ruby's COW mechanism to just reference the slice data
	      self.class.new(@data.slice(start, len))
	    end
	    def at(index)
	      @data[index]
	    end
	    def each(&block)
	      @data.each_char(&block)
	    end
	    def to_s(s="")
	      s.concat(@data.to_s)
	    end
	  end
	end

Note here that slice() was overridden to return a StringRope instead of a
String.  As the comment says, Ruby internally uses some Copy On Write semantics
to reference sliced Strings.  This should keep it from wildly duplicating the
data, but it was found that a couple of solutions had problems with this for
unknown reasons.

That covers a basic Rope implementation.  We won't bother to go into the
destructive methods as you are probably better off working without them.

My thanks to all who explored this newly popular data structure with us.  It
looks like there will be a talk on ropes at this year's Rubyconf, so hopefully
we gave the speaker some extra material to work with.

This week's Ruby Quiz will start a day early, to adjust for my Lone Star
Rubyconf schedule this weekend.  The no-spoiler period is still 48 hours and I
will still summarize it at the same time, you just get an extra day to work on
it.  Stay tuned for that problem in just a few minutes...

In This Thread

Prev Next