[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] Dwemthy's Array -- the Ruby mini_adventure

why the lucky stiff

3/23/2005 5:11:00 PM

Since you were a very young rabbit in little cotton pants, Dwemthy's
Array has breathed on your neck and you're tired of it. You draw your
glistening Hero's Sword from its sheath and cut a low-circling falcon in
half as a confidence building exercise. Your eyes flick about in a cool
and freaky way.

You're ready... It's time to stare this construct in the face.

$$$ DWEMTHY_S ARRAY ^!^ A RUBY MINI_DUNGEON ^!^ CODE TO KILL BY $$$

Here, try this: http://poignantguide.ne...

The sixth chapter of Why's (Poignant) Guide to Ruby is on its way. This
chapter covers metaclasses and method_missing with the help of Dwemthy's
demonic list. The code for the little RPG is now available. A full
explanation is forthcoming in chapter six.

Please send your hacks to the poignant-stiffs list. Subscription
information is at http://poignant.ruby....

_why



16 Answers

Shajith

3/23/2005 5:24:00 PM

0

On Thu, 24 Mar 2005 02:11:29 +0900, why the lucky stiff
<ruby-talk@whytheluckystiff.net> wrote:
>
> Here, try this: http://poignantguide.ne...
>

Man.. I'm in tears here.
*sob*

>
> _why
>

Shajith

PS: Hurry up with chapter 6, will ya? :D


Jacob Fugal

3/23/2005 6:07:00 PM

0

On Thu, 24 Mar 2005 02:11:29 +0900, why the lucky stiff
<ruby-talk@whytheluckystiff.net> wrote:
> You're ready... It's time to stare this construct in the face.
>
> $$$ DWEMTHY_S ARRAY ^!^ A RUBY MINI_DUNGEON ^!^ CODE TO KILL BY $$$
>
> Here, try this: http://poignantguide.ne...

Is it just me or is the DwemthysArray symbol never defined on that
page? I defeated the ScubaArgentine and am eager to fight the Dragon!

- Jacob Fugal


why the lucky stiff

3/23/2005 6:25:00 PM

0

Jacob Fugal wrote:

> Is it just me or is the DwemthysArray symbol never defined on that
>
>page? I defeated the ScubaArgentine and am eager to fight the Dragon!
>
Well done, hero. You have discovered a weakness in Dwemthy's Array!!
This has been a crucial part of your training. You have learned to spot
omissions in the mechanisms of life!! ANd you have charged up to the
great god of the sky and thrust your javelin in the sky and bellowed
great screams, chiding the powers of speed and atmosphere, that you will
not accept this, that your honor and nobility is owed far greater than
this!!

Well done, I say. Raise a chalice of valor!! Let the mead flow thickly
through our devoursome fingers and ankle beards!!

_why


ptkwt

3/23/2005 6:57:00 PM

0

In article <50756767050323100730f7f739@mail.gmail.com>,
Jacob Fugal <lukfugl@gmail.com> wrote:
>On Thu, 24 Mar 2005 02:11:29 +0900, why the lucky stiff
><ruby-talk@whytheluckystiff.net> wrote:
>> You're ready... It's time to stare this construct in the face.
>>
>> $$$ DWEMTHY_S ARRAY ^!^ A RUBY MINI_DUNGEON ^!^ CODE TO KILL BY $$$
>>
>> Here, try this: http://poignantguide.ne...
>
>Is it just me or is the DwemthysArray symbol never defined on that
>page? I defeated the ScubaArgentine and am eager to fight the Dragon!
>

No one knows how those hideous creatures got in DwemthysArray and no one
knows where DwemthysArray comes from either.

....yeah, I ran into the same problem.

How about:

dwar = [IndustrialRaverMonkey.new,
DwarvenAngel.new,
AssistantViceTentacleAndOmbudsman.new,
TeethDeer.new,
IntrepidDecomposedCyclist.new,
Dragon.new]

dwar.each {|creature|
r ^ creature
}

....but I get:

[Rabbit is too dead to fight!]
[Rabbit is too dead to fight!]
[Rabbit is too dead to fight!]
[Rabbit is too dead to fight!]
[Rabbit is too dead to fight!]
[Rabbit is too dead to fight!]

No doubt _why has put some magic in DwemthysArray that we're missing.

Phil


Patrick Hurley

3/23/2005 8:07:00 PM

0

> No doubt _why has put some magic in DwemthysArray that we're missing.

He has that cool method_missing stuff where the method you are trying
to use against his array is sent to the first item in the array. If
the life trait runs out of the entry he shifts it out and brings on
the next one. It is a nice little idiom -- I like it.

Of course the only way I could beat the array was with a little smoke
and mirrors:

r = Rabbit.new
r.life = 9999

seemed to help a lot :-)


why the lucky stiff

3/24/2005 12:32:00 AM

0

Patrick Hurley wrote:
>
> r = Rabbit.new
> r.life = 9999
>

See, hex-editing is 10x fasterrr in Ruby, too.

ALls I can say is: you sure skipped a lot of lettuce-eating.

_why



Patrick Hurley

3/24/2005 12:38:00 AM

0

Oh btw, if you keep at it the DwemthysArray gets a little nasty
sending messages to Nil and nil does not seem to appreciate the extra
attention. So a minor change like below seems to help.

Thanks as always for the enjoyable read, yours is one of the more
interesting ways to introduce people to Ruby.

Patrick

*** dwemthy-orig.rb Wed Mar 23 14:33:52 2005
--- dwemthy.rb Wed Mar 23 15:20:07 2005
***************
*** 64,76 ****
alias _inspect inspect
def inspect; "#<#{ self.class }#{ _inspect }>"; end
def method_missing( meth, *args )
answer = first.send( meth, *args )
! if first.life <= 0
! shift
! if empty?
! puts "[Whoa. You decimated Dwemthy's Array!]"
! else
! puts "[Get ready. #{ first.class } has emerged.]"
end
end
answer || 0
--- 64,80 ----
alias _inspect inspect
def inspect; "#<#{ self.class }#{ _inspect }>"; end
def method_missing( meth, *args )
+ if empty?
+ puts "[Quit flogging my dead monsters!]"
+ else
answer = first.send( meth, *args )
! if first.life <= 0
! shift
! if empty?
! puts "[Whoa. You decimated Dwemthy's Array!]"
! else
! puts "[Get ready. #{ first.class } has emerged.]"
! end
end
end
answer || 0


vruz

3/24/2005 1:30:00 AM

0

> Since you were a very young rabbit in little cotton pants, Dwemthy's
> Array has breathed on your neck and you're tired of it. You draw your
> glistening Hero's Sword from its sheath and cut a low-circling falcon in
> half as a confidence building exercise. Your eyes flick about in a cool
> and freaky way.

shine on you crazy diamond


Shalev NessAiver

3/24/2005 1:53:00 AM

0

On Mar 23, 2005, at 7:32 PM, why the lucky stiff wrote:
>
> ALls I can say is: you sure skipped a lot of lettuce-eating.
>
> _why
>
>


Yeah, I figured that part out. The only way is to frngllheeg aahhh
help- askdfjj.

[ Sorry about that folks, Shalev was called away on an emergency.
Go back to your normal lives people. ]

Brian McCallister

3/24/2005 1:58:00 PM

0

r = Rabbit.new
1000000.times { r % r }

is maybe a bit less of a hack ;-)

technically

maybe

-Brian

On Mar 23, 2005, at 8:52 PM, Shalev NessAiver wrote:

> On Mar 23, 2005, at 7:32 PM, why the lucky stiff wrote:
>>
>> ALls I can say is: you sure skipped a lot of lettuce-eating.
>>
>> _why
>>
>>
>
>
> Yeah, I figured that part out. The only way is to frngllheeg aahhh
> help- askdfjj.
>
> [ Sorry about that folks, Shalev was called away on an emergency.
> Go back to your normal lives people. ]
>