--a+b56+3nqLzpiR9O
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Jun 12, 2007 at 03:10:49AM +0900, Bas van Gils wrote:
>=20
> All,
>=20
> A little while ago I picked up a copy of the pickaxe book and got hooked =
to
> Ruby. Never had a `real' project to work on though (that's what you get w=
hen
> you don't hack for a living I suppose
. Either way, a few weeks back I
> needed an app that generates deals for the card game bridge. I made a sma=
ll
> design and hacked up some unit tests. After a while no more tests failed:
[snip]=20
> Not bad... Like I said, I'm not a full-time programmer. I would *love* to
> learn more about `proper' ruby style though. Is there even such a thing? I
> mean, the book cover said something about *pragmatic* 
>=20
> Could anyone have a look at:
>=20
> http://www.van-gils.org/~bas/bridgehands/
>=20
> and give me some suggestions on style / ruby idiom / other things?
>=20
> Any help would be greatly appreciated,
=46rom what I've been led to understand, method names consisting of
multiple words should be named_with_underscores, not namedWithCamelcase.
`puts' is the same as `print "something\n"'
Parens can be omitted if it doesn't confuse the parser (or the reader)
As well, reserve the { } form of blocks to one-liners.
Taking these into account, instead of writing (from
http://www.van-gils.org/~bas/bridgehands/deal.rb):
bg.suits.each{ |suit|
cards =3D bg.north.cardsOfSuit(suit)
print " #{bg.sortCards(cards)} \n"
}
write something like
bg.suits.each do |suit|
cards =3D bg.north.cards_of_suit suit
puts " #{bg.sort_cards(cards)} "
end
Then again, these are highly subjective views, ones that I've absorbed
=66rom reading other people's ruby and getting into arguments with friends

Take them with a grain of salt, as I'm not a Ruby expert and thus I
might be wrong.
>=20
> yours=20
>=20
> Bas
>=20
> --=20
> Bas van Gils <>, http://www.van-gils.org
> [[[ Thank you for not distributing my E-mail address ]]]
>=20
> Quod est inferius est sicut quod est superius, et quod est superius est s=
icut
> quod est inferius, ad perpetranda miracula rei unius.
>=20
>=20
--=20
C makes it easy to shoot yourself in the foot; C++ makes it harder, but whe=
n you
do succeed, you will blow away your whole leg.
-- Bjarne Stroustrup
--a+b56+3nqLzpiR9O
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGbZbwKaiGM/xGKzQRArZ9AKCO/UYU4CIMl88wmMUB8XtdPiGppQCgxZgd
7Pt59vARuNASADT/+COx97E=
=3FIb
-----END PGP SIGNATURE-----
--a+b56+3nqLzpiR9O--