#- - - - - - - - - - - - - -#
# #
# a bit about bouncing #
# by: evan #
# #
#- - - - - - - - - - - - - -#
module Bouncing

# first of all:
def it_is_ok
# ok?
"ok."
end

# but:
# when a thing
def hits_the_ground_from the_height
# if we can assume that the
remaining_energy = the_height

# then we can say
if remaining_energy
that_the "thing uses some of the #{remaining_energy} to bounce"
# and
rises_to the_next_peak_from(the_height)

else
# the thing just
rests
# and that is the
end # of it
end

# it should be noted that:

# in order to determine the
def the_next_peak_from the_old_height;
unless the_old_height < an_observable_bounce
# we assume that
new_height = the_old_height * the_bounciness
else
# the thing is no longer bouncing
# percievable to this observer, anyway...
end
end

# also,
# when a thing
# is dropped
def from a_height # it
hits_the_ground_from a_height
end

# likewise,
# when a thing
def rises_to a_new_height
# then it will fall
from a_new_height
end

# but...

# and most importantly.

# when the time is just right,

# the thing just

def rests;

and_we_know it_is_ok

#the
end

#----------------------------------------------#

alias :and_we_know :puts
alias :that_the :puts
def the_bounciness; @bounciness end
def an_observable_bounce
@minimum_bounce end

def bounciness=(amnt) @bounciness = amnt end
def minimum_bounce=(amnt)
@minimum_bounce = amnt end

end


## and a thing

class Thing
include Bouncing
def self.with_bounciness(bounce)
thing = new
thing.bounciness = bounce
thing
end
def dropped_from height
yield(self)
hits_the_ground_from height
end
end

## and then you run it...

Thing.with_bounciness(0.5).dropped_from(50) { |set|
set.minimum_bounce = 0.01
}

## and it says:

thing uses some of the 50 to bounce
thing uses some of the 25.0 to bounce
thing uses some of the 12.5 to bounce
thing uses some of the 6.25 to bounce
thing uses some of the 3.125 to bounce
thing uses some of the 1.5625 to bounce
thing uses some of the 0.78125 to bounce
thing uses some of the 0.390625 to bounce
thing uses some of the 0.1953125 to bounce
thing uses some of the 0.09765625 to bounce
thing uses some of the 0.048828125 to bounce
thing uses some of the 0.0244140625 to bounce
thing uses some of the 0.01220703125 to bounce
thing uses some of the 0.006103515625 to bounce
ok.