On Fri, 26 Sep 2008, Bluebie, Jenna wrote:
> Since those method names are supposedly being handled by a method_missing
> somewhere, I see no reason why it couldn't .gsub(/_/, '') all the underscores
> out and let users underscore however they please. :)
delete('_') would be faster I suspect
$ ruby -e "puts 'Do I have to spell it out C_H_E_E_S_E A_N_D
O_N_I_O_N_S'.delete('_')"
Do I have to spell it out CHEESE AND ONIONS
[Is "The Rutles" a sufficiently obscure reference?]
Hugh
>
>
> On 26/09/2008, at 5:59 AM, Seth Thomas Rasmussen wrote:
>
> > So, about widgets.. some example code from a recent thread:
> >
> > On Thu, Sep 25, 2008 at 1:59 PM, Joshua Choi <[EMAIL PROTECTED]> wrote:
> > > class TestingWidget1 < Widget
> > >
> > > def initialize &optional_block
> > > if block_given?
> > > para 'This block was given to me: ', optional_block.inspect
> > > else
> > > para 'A block was not given to me. In other words,
> > > optional_block == nil'
> > > end
> > > end
> > >
> > > end
> > >
> > > class TestingWidget2 < Widget
> > >
> > > def initialize &optional_block
> > > if block_given?
> > > para 'I got a block, even though I should not have one!'
> > > else
> > > para 'I did not get a block, which is what should happen.'
> > > end
> > > end
> > >
> > > end
> > >
> > > Shoes.app do
> > >
> > > testingwidget1 do
> > > para 'I am inside a block.'
> > > end
> > >
> > > testingwidget1
> > >
> > > testingwidget2
> > >
> > > end
> >
> > I think it would be nicer if the generated method names had
> > underscores to mark the separation of words. e.g. SuperMegaWidget
> > becomes super_mega_widget.
> >
> > --
> > Seth Thomas Rasmussen
> > http://greatseth.com