Well it was actually quite a small one off script but it led me to
wondering... Yes John, I want it to fall through like C - is that
possible? Thanks Robert for the useful alternative method. I'm pretty
new to Ruby and haven't actually got so far as to thinking of
everything in terms of classes so this was just a small script written
procedurally rather than in a class based way.

On Jul 9, 10:23 am, "Robert Klemme" <shortcut... / googlemail.com>
wrote:
> Apparently my newsgroup reply has not made it to the mailing list
> (yet).  Apologies if you receive two answers.
>
> 2007/7/6, John Joyce <dangerwillrobinsondan... / gmail.com>:
>
>
>
>
>
> > On Jul 6, 2007, at 4:19 AM, Robert Klemme wrote:
>
> > > 2007/7/6, tobyclem... / gmail.com <tobyclem... / gmail.com>:
> > >> Basically I had a situation where dependent on the formatting of a
> > >> block of text, different actions had to be carried out but some
> > >> actions were common to each of the formattings whereas others weren't
> > >> so I really wanted to be able to apply the bits that were specific to
> > >> say the type 1 format first and then follow down into the actions
> > >> common to both type 1 and type 2 such as is the case in other
> > >> languages when you don't 'break' out of each 'case' clause. I
> > >> understand now that all 'case' clauses in ruby automatically 'break'
> > >> when they finish but I was wondering whether there was a way around
> > >> that such as in my code example. It appears though that in my code
> > >> block, the first 'when' clause fulfilling the condition is executed
> > >> and then the 'case' is exited. I wanted to know whether there was a
> > >> way to stop the 'case' exiting so that it continues and carries out
> > >> the actions in the next 'when' clause fulfilling the condition.
> > >> And if
> > >> there isn't a way to do this, what is the best way to achieve the
> > >> functionality I am trying to obtain.
>
> > > I do not know how complex your operations are. From what you write I
> > > guess there could be multiple actions and they could be complex. Also,
> > > there might be numerous formats - if not today then maybe in a later
> > > stage. Going from there the solution I'd probably favor is a class
> > > hierarchy of formatters.  That way you can define some basic
> > > formatting functionality in methods in the base class and use those
> > > methods from all sub class methods.
>
> > > You then only need to map your format code in some way to the name of
> > > a specific formatter class and send the request off to that to get
> > > your specific formatting.  For the mapping you can use various
> > > mechanisms, the easiest probably being the class name of the
> > > formatter.  But you can as well use some specific mapping using a
> > > Hash.  There are other methods as well.
>
> > > Kind regards
>
> > > robert
>
> > you mean you want it to fall through like in C?
>
> No. My suggestion has nothing to do with "case" statements.  It's an
> OO way of doing this.
>
> Kind regards
>
> robert