[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: How to exit Ruby program properly

Daniel Sheppard

12/13/2005 5:01:00 AM

Process.exit is the way to go (or just putting the rest of your logic
into the else section of that if statement).

There is nothing unclean about the fact that Process.exit raises an
exception. The fact that it raises an exception is noted to allow other
methods up the chain to intercept and possibly prevent the shutdown.

It also ensures that all the "ensure" thingies up the chain get
executed, so that you file output can be flushed and handles closed and
any other shutdown procedures can come into play. For example:

file = File.new("outfile","w")
begin
f.puts "Monkeys are cool"
Process.exit
ensure
f.close
puts "File flushed properly"
end

(Note that you'd usually pass a block to File.open, which does the
begin/ensure/close/end bit for you)

If you REALLY want to exit NOW, you can use Process.exit!, but generally
you don't want to do that. Change the above the use Process.exit!, and
you'll notice that "File flushed properly" will not be output - imagine
if there was a more important ensure clause hanging around.


> -----Original Message-----
> From: list-bounce@example.com
> [mailto:list-bounce@example.com] On Behalf Of Jeff Cohen
> Sent: Tuesday, 13 December 2005 2:57 PM
> To: ruby-talk ML
> Subject: How to exit Ruby program properly
>
> I'm learning to write ruby code, and I'm using 1.8.2 on Windows XP.
> What is the best way to exit from my .rb script?
>
> I'm using Process.exit but the documentation implies that it
> will throw
> an exception. So I'm guessing there's a "cleaner" way to exit?
>
> For example:
>
> test.rb
> ====================
> if ARGV.length == 0
> puts "Please specify a filename"
> Process.exit
> end
>
> # script continues here...
>
>
> Thanks!
> Jeff
>
> --
> Posted via http://www.ruby-....
>
>
>
#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################


16 Answers

Mrcheerful

9/19/2009 11:33:00 AM

0

Michael Swift wrote:
> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue <blue@there.com>
> writes
>> Sales and Scammers must be going mad this summer.
>
> I've lost count of the number of holidays, vouchers and free offers
> I've won this year, all 'out of area' or 'international' and all
> number withheld. I'm rarely troubled by British phone spam thanks to
> the TPS.
>
> Mike

Ah, you mean the calls that start 'Congratulations, you've won ......' I get
the phone back down before I hear any more.

I have caller display, anonymous caller rejection, choose to refuse and TPS
listing, so like you it is only the International ones that get through.
About one every few months usually starting as above.


Sam

9/19/2009 11:39:00 AM

0


"Michael Swift" <mike.swift@yeton.co.uk> wrote in message
news:zfTHaVASpLtKFwtV@ntlworld.com...
> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue <blue@there.com>
> writes
>>Sales and Scammers must be going mad this summer.
>
> I've lost count of the number of holidays, vouchers and free offers I've
> won this year, all 'out of area' or 'international' and all number
> withheld. I'm rarely troubled by British phone spam thanks to the TPS.

I get at least 20 withheld and international numbers calling me every day.
On almost every occasion, it's someone trying to flog me something or asking
me to do a survey of some sort.
I now don't answer withheld numbers, overseas numbers, and ones that don't
start with a regular 01 dialing code.
I let them go to the answering machine to screen them, and if I want to take
the call, I pick up when they identify themselves.
Often, they hang up as soon as the answering machine kicks in. Their loss,
not mine.

Another trend that I despise nowadays is their refusal to identify
themselves when they call.
If I do get caught speaking to one of these shysters, I ask them 3 times
"Who's calling please?"
If on the third attempt, they still haven't identified themselves, I
terminate the call.


Brimstone

9/19/2009 11:57:00 AM

0

Sam wrote:
> "Michael Swift" <mike.swift@yeton.co.uk> wrote in message
> news:zfTHaVASpLtKFwtV@ntlworld.com...
>> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue
>> <blue@there.com> writes
>>> Sales and Scammers must be going mad this summer.
>>
>> I've lost count of the number of holidays, vouchers and free offers
>> I've won this year, all 'out of area' or 'international' and all
>> number withheld. I'm rarely troubled by British phone spam thanks to
>> the TPS.
>
> I get at least 20 withheld and international numbers calling me every
> day. On almost every occasion, it's someone trying to flog me
> something or asking me to do a survey of some sort.
> I now don't answer withheld numbers, overseas numbers, and ones that
> don't start with a regular 01 dialing code.
> I let them go to the answering machine to screen them, and if I want
> to take the call, I pick up when they identify themselves.
> Often, they hang up as soon as the answering machine kicks in. Their
> loss, not mine.
>
> Another trend that I despise nowadays is their refusal to identify
> themselves when they call.
> If I do get caught speaking to one of these shysters, I ask them 3
> times "Who's calling please?"
> If on the third attempt, they still haven't identified themselves, I
> terminate the call.

Often when picking up the phone there is a delay before there is someone to
talk to me. I usually hang up then.


Sam

9/19/2009 12:07:00 PM

0


"Brimstone" <brimstone520-ng06@yahoo.co.uk> wrote in message
news:Is2dnf3yco6aWinXnZ2dnUVZ8nWdnZ2d@bt.com...
> Sam wrote:
>> "Michael Swift" <mike.swift@yeton.co.uk> wrote in message
>> news:zfTHaVASpLtKFwtV@ntlworld.com...
>>> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue
>>> <blue@there.com> writes
>>>> Sales and Scammers must be going mad this summer.
>>>
>>> I've lost count of the number of holidays, vouchers and free offers
>>> I've won this year, all 'out of area' or 'international' and all
>>> number withheld. I'm rarely troubled by British phone spam thanks to
>>> the TPS.
>>
>> I get at least 20 withheld and international numbers calling me every
>> day. On almost every occasion, it's someone trying to flog me
>> something or asking me to do a survey of some sort.
>> I now don't answer withheld numbers, overseas numbers, and ones that
>> don't start with a regular 01 dialing code.
>> I let them go to the answering machine to screen them, and if I want
>> to take the call, I pick up when they identify themselves.
>> Often, they hang up as soon as the answering machine kicks in. Their
>> loss, not mine.
>>
>> Another trend that I despise nowadays is their refusal to identify
>> themselves when they call.
>> If I do get caught speaking to one of these shysters, I ask them 3
>> times "Who's calling please?"
>> If on the third attempt, they still haven't identified themselves, I
>> terminate the call.
>
> Often when picking up the phone there is a delay before there is someone
> to talk to me. I usually hang up then.

Occasionally, if I'm in a funny mood, I'll play games with them to see how
long I can keep them on the phone...But I have to ber seriously bored to do
that.


Periander

9/19/2009 12:11:00 PM

0

"Brimstone" <brimstone520-ng06@yahoo.co.uk> wrote in
news:Is2dnf3yco6aWinXnZ2dnUVZ8nWdnZ2d@bt.com:

> Sam wrote:
>> "Michael Swift" <mike.swift@yeton.co.uk> wrote in message
>> news:zfTHaVASpLtKFwtV@ntlworld.com...
>>> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue
>>> <blue@there.com> writes
>>>> Sales and Scammers must be going mad this summer.
>>>
>>> I've lost count of the number of holidays, vouchers and free offers
>>> I've won this year, all 'out of area' or 'international' and all
>>> number withheld. I'm rarely troubled by British phone spam thanks to
>>> the TPS.
>>
>> I get at least 20 withheld and international numbers calling me every
>> day. On almost every occasion, it's someone trying to flog me
>> something or asking me to do a survey of some sort.
>> I now don't answer withheld numbers, overseas numbers, and ones that
>> don't start with a regular 01 dialing code.
>> I let them go to the answering machine to screen them, and if I want
>> to take the call, I pick up when they identify themselves.
>> Often, they hang up as soon as the answering machine kicks in. Their
>> loss, not mine.
>>
>> Another trend that I despise nowadays is their refusal to identify
>> themselves when they call.
>> If I do get caught speaking to one of these shysters, I ask them 3
>> times "Who's calling please?"
>> If on the third attempt, they still haven't identified themselves, I
>> terminate the call.
>
> Often when picking up the phone there is a delay before there is
> someone to talk to me. I usually hang up then.

I always say words to the effect of, "Oh yes, that sounds really
interesting/good, please tell me more" then after 30 seconds or so,
"Just hold the line a minute please there's someone at the door". Then
put the phone down - not hanging up and go back to waht I'm doing ...

After 30 minutes or so, check the phone, find its been hung up at the
other end :-) .. It's not my bill.

--

Regards,


Periander

Brimstone

9/19/2009 12:13:00 PM

0

Periander wrote:
> "Brimstone" <brimstone520-ng06@yahoo.co.uk> wrote in
> news:Is2dnf3yco6aWinXnZ2dnUVZ8nWdnZ2d@bt.com:
>
>> Sam wrote:
>>> "Michael Swift" <mike.swift@yeton.co.uk> wrote in message
>>> news:zfTHaVASpLtKFwtV@ntlworld.com...
>>>> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue
>>>> <blue@there.com> writes
>>>>> Sales and Scammers must be going mad this summer.
>>>>
>>>> I've lost count of the number of holidays, vouchers and free offers
>>>> I've won this year, all 'out of area' or 'international' and all
>>>> number withheld. I'm rarely troubled by British phone spam thanks
>>>> to the TPS.
>>>
>>> I get at least 20 withheld and international numbers calling me
>>> every day. On almost every occasion, it's someone trying to flog me
>>> something or asking me to do a survey of some sort.
>>> I now don't answer withheld numbers, overseas numbers, and ones that
>>> don't start with a regular 01 dialing code.
>>> I let them go to the answering machine to screen them, and if I want
>>> to take the call, I pick up when they identify themselves.
>>> Often, they hang up as soon as the answering machine kicks in. Their
>>> loss, not mine.
>>>
>>> Another trend that I despise nowadays is their refusal to identify
>>> themselves when they call.
>>> If I do get caught speaking to one of these shysters, I ask them 3
>>> times "Who's calling please?"
>>> If on the third attempt, they still haven't identified themselves, I
>>> terminate the call.
>>
>> Often when picking up the phone there is a delay before there is
>> someone to talk to me. I usually hang up then.
>
> I always say words to the effect of, "Oh yes, that sounds really
> interesting/good, please tell me more" then after 30 seconds or so,
> "Just hold the line a minute please there's someone at the door". Then
> put the phone down - not hanging up and go back to waht I'm doing ...
>
> After 30 minutes or so, check the phone, find its been hung up at the
> other end :-) .. It's not my bill.

Indeed, and you're saving some other poor sod from having to listen to the
crap.


True Blue

9/19/2009 12:18:00 PM

0


"Sam" <sam@btinternet.com> wrote in message
news:9_ydnfZvWfByXynXnZ2dnUVZ8rGdnZ2d@bt.com...
>
> "Michael Swift" <mike.swift@yeton.co.uk> wrote in message
> news:zfTHaVASpLtKFwtV@ntlworld.com...
>> In article <7hjkq0F2t70h3U1@mid.individual.net>, Blue <blue@there.com>
>> writes
>>>Sales and Scammers must be going mad this summer.
>>
>> I've lost count of the number of holidays, vouchers and free offers I've
>> won this year, all 'out of area' or 'international' and all number
>> withheld. I'm rarely troubled by British phone spam thanks to the TPS.
>
> I get at least 20 withheld and international numbers calling me every day.
> On almost every occasion, it's someone trying to flog me something or
> asking me to do a survey of some sort.
> I now don't answer withheld numbers, overseas numbers, and ones that don't
> start with a regular 01 dialing code.
> I let them go to the answering machine to screen them, and if I want to
> take the call, I pick up when they identify themselves.
> Often, they hang up as soon as the answering machine kicks in. Their loss,
> not mine.
>
> Another trend that I despise nowadays is their refusal to identify
> themselves when they call.
> If I do get caught speaking to one of these shysters, I ask them 3 times
> "Who's calling please?"
> If on the third attempt, they still haven't identified themselves, I
> terminate the call.

You mean you terminate your enjoyment. Phone scammers are a legitimate
target for fun! The next time you get a call that isn't a recorded message,
just say the "home owner" is at the bottom of the garden....."would you like
me to fetch him?" - just listen to the apprehension in their voice when they
answer.

Norman Wells

9/19/2009 12:19:00 PM

0

Periander wrote:

> After 30 minutes or so, check the phone, find its been hung up at the
> other end :-) .. It's not my bill.

It's probably not theirs either. It will all be done over the internet.

abs

9/19/2009 12:54:00 PM

0

On Sat, 19 Sep 2009 12:39:25 +0100, "Sam" <sam@btinternet.com> wrote:


>I get at least 20 withheld and international numbers calling me every day.
I do not know how you manage to get this number of calls Sam my number
is withheld and if I get three a year it will be most unusual and I am
most careful to make sure I do not give out my BT number to anyone I
don't know .Tradesmen and others that I do not know personally are
given my mobile number .

jt

9/19/2009 6:28:00 PM

0

Mrcheerful <nbkm57@hotmail.co.uk> wrote

> Michael Swift wrote:
> > Blue <blue@there.com> writes
> >> Sales and Scammers must be going mad this summer.
> >
> > I've lost count of the number of holidays, vouchers and free offers
> > I've won this year, all 'out of area' or 'international' and all
> > number withheld. I'm rarely troubled by British phone spam thanks
to
> > the TPS.

Don't you get "unavailable" aka (1471) "we do not have the number ..."
or does your phone call such "out of area" ?

And if they are "all number withheld" how do you know anything more ?

> Ah, you mean the calls that start 'Congratulations, you've won
......' I get
> the phone back down before I hear any more.
>
> I have caller display, anonymous caller rejection, choose to refuse
and TPS
> listing, so like you it is only the International ones that get
through.
> About one every few months usually starting as above.

Does ACR stop "unavailable" CLID calls now ?

--
Mike D
(BT Privacy gives CLID free subject to 6 calls/quarter).