[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[quesion] require just in a context?

cap

3/3/2006 3:13:00 AM

Can I make some libraray just work in a context ?

I add a new ruby file into my app using "require 'mathn'" but i don't
want every ruby file to use the 'mathn', how can I do it?

9 Answers

Yuu

3/3/2006 7:03:00 PM

0

cap wrote:
> Can I make some libraray just work in a context ?
>
> I add a new ruby file into my app using "require 'mathn'" but i don't
> want every ruby file to use the 'mathn', how can I do it?

Well, anytime you call #require, the effect will be global.
You can delay the call until a certain point in your program
(possibly useful if there is a possibility that it would not
be loaded at all) since #require is just a method. For example,

def foobar(x, y)
require 'mathn'
# ...
end

Would be fine (but would still have an effect just like if
you did it at the top of the file).

As an alternative, you could wrap the loaded file into a
module either using #load which can use an anonymous module
(see the docs) or a library such as Script (see RAA) which
uses a named module. This approach might not work with mathn
or anything else that modifies existing classes.


E

--
Posted via http://www.ruby-....


Joel VanderWerf

3/4/2006 12:41:00 AM

0

E. Saynatkari wrote:
> cap wrote:
>> Can I make some libraray just work in a context ?
>>
>> I add a new ruby file into my app using "require 'mathn'" but i don't
>> want every ruby file to use the 'mathn', how can I do it?
>
> Well, anytime you call #require, the effect will be global.
> You can delay the call until a certain point in your program
> (possibly useful if there is a possibility that it would not
> be loaded at all) since #require is just a method. For example,
>
> def foobar(x, y)
> require 'mathn'
> # ...
> end
>
> Would be fine (but would still have an effect just like if
> you did it at the top of the file).
>
> As an alternative, you could wrap the loaded file into a
> module either using #load which can use an anonymous module
> (see the docs) or a library such as Script (see RAA) which
> uses a named module. This approach might not work with mathn
> or anything else that modifies existing classes.

Nope. If you Kernel#load or Module#module_eval a file which requires
mathn, the effect will still be global.

$ ruby -e 'load "foo.rb"; p 1/2'
1/2
$ ruby -e 'm=Module.new; m.module_eval(File.read("foo.rb")); p 1/2'
1/2
$ ruby -v
ruby 1.8.4 (2005-12-24) [i686-linux]

I think what you want is something called behaviors. See the list
archives...

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


1st

7/15/2010 10:38:00 AM

0

On Jul 15, 3:36 am, Hans <h...@siegecraft.us> wrote:
> Looking at the numbers on the datasheets, there's no reason to use a
> straight 7408 anymore.
>
> On all my system 6-7 driver board work, I'm only using the 74F08's
> now, even if I can get the 7408's.
> The 74F08's can handle the job just fine, they draw less power, switch
> faster, and cost less.   If there's a drawback, I haven't found one.

Ed, does your site crossreference items like this or do we have to ask
on e-mail?

Thanks,
1st

Hunty

7/15/2010 3:10:00 PM

0

On Jul 15, 12:36 am, "GPE" <GPE_NoS...@Cox.net> wrote:
> "Hunty" <luvcr...@gmail.com> wrote in message
>
> news:4fda89c8-e674-47b8-a9dd-3ce0cdf32c59@z30g2000prg.googlegroups.com...
>
> > mouser tells me that 7408s are "obsolete". I see that I can still get
> > them from GPE, but is there a better replacement IC I should use
> > instead?
>
> Long dead...unfortunately.
> Old logic is slowly dying off one part number at a time.
>
> For replacements - it depends on what you are using it for.
> If using it in a low current load application, go with 74HCT08.
> For a high current load, use a 74F08.
> Where is this used?
>
> Ed

solenoid driver circuit on a Sys11. I presume I want a 74F08, then?

Hans

7/15/2010 5:38:00 PM

0

On Jul 15, 11:10 am, Hunty <luvcr...@gmail.com> wrote:
> On Jul 15, 12:36 am, "GPE" <GPE_NoS...@Cox.net> wrote:
>
>
>
> > "Hunty" <luvcr...@gmail.com> wrote in message
>
> >news:4fda89c8-e674-47b8-a9dd-3ce0cdf32c59@z30g2000prg.googlegroups.com...
>
> > > mouser tells me that 7408s are "obsolete". I see that I can still get
> > > them from GPE, but is there a better replacement IC I should use
> > > instead?
>
> > Long dead...unfortunately.
> > Old logic is slowly dying off one part number at a time.
>
> > For replacements - it depends on what you are using it for.
> > If using it in a low current load application, go with 74HCT08.
> > For a high current load, use a 74F08.
> > Where is this used?
>
> > Ed
>
> solenoid driver circuit on a Sys11. I presume I want a 74F08, then?

Yep, that's the one for the application.

GPE

7/15/2010 6:44:00 PM

0

On Jul 15, 5:38 am, 1st <kybr...@stny.rr.com> wrote:
> On Jul 15, 3:36 am, Hans <h...@siegecraft.us> wrote:
>
> > Looking at the numbers on the datasheets, there's no reason to use a
> > straight 7408 anymore.
>
> > On all my system 6-7 driver board work, I'm only using the 74F08's
> > now, even if I can get the 7408's.
> > The 74F08's can handle the job just fine, they draw less power, switch
> > faster, and cost less.   If there's a drawback, I haven't found one.
>
> Ed, does your site crossreference items like this or do we have to ask
> on e-mail?
>
> Thanks,
> 1st

I don't have a cross reference at this time.
I keep meaning to add this sort of thing but never find the time.
What I -want- to do is add a picture of each board on my website. You
click on the part in the picture that you need and the link takes you
to the recommended replacement part.
But... just can't find the time.

Ed

pinball brian

7/15/2010 7:13:00 PM

0

On Jul 15, 1:43 pm, GPE <G...@Cox.net> wrote:

> What I -want- to do is add a picture of each board on my website.  You
> click on the part in the picture that you need and the link takes you
> to the recommended replacement part.
> But... just can't find the time.
>
> Ed

That would be really cool! :)

1st

7/15/2010 7:22:00 PM

0

That would be cool. I need that <click>, and that <click>, place
order.
Gotta be a pinhead out there that could set that up for you.

1st

On Jul 15, 2:43 pm, GPE <G...@Cox.net> wrote:

> I don't have a cross reference at this time.
> I keep meaning to add this sort of thing but never find the time.
> What I -want- to do is add a picture of each board on my website.  You
> click on the part in the picture that you need and the link takes you
> to the recommended replacement part.
> But... just can't find the time.
>
> Ed

Chris Hibler

7/16/2010 2:47:00 AM

0

On Jul 15, 1:43 pm, GPE <G...@Cox.net> wrote:
> On Jul 15, 5:38 am, 1st <kybr...@stny.rr.com> wrote:
>
> > On Jul 15, 3:36 am, Hans <h...@siegecraft.us> wrote:
>
> > > Looking at the numbers on the datasheets, there's no reason to use a
> > > straight 7408 anymore.
>
> > > On all my system 6-7 driver board work, I'm only using the 74F08's
> > > now, even if I can get the 7408's.
> > > The 74F08's can handle the job just fine, they draw less power, switch
> > > faster, and cost less.   If there's a drawback, I haven't found one.
>
> > Ed, does your site crossreference items like this or do we have to ask
> > on e-mail?
>
> > Thanks,
> > 1st
>
> I don't have a cross reference at this time.
> I keep meaning to add this sort of thing but never find the time.
> What I -want- to do is add a picture of each board on my website.  You
> click on the part in the picture that you need and the link takes you
> to the recommended replacement part.
> But... just can't find the time.
>
> Ed

That would be cool Ed.
But, I'll let you know, that the cross or "update" info you have on
your site is very useful to me. For instance...if you search your site
for 2N5060, it points you to the 2N5064. Very nice...
--
Chris Hibler - CARGPB #31
http://www.T...
http://webpages.charter.net/chibler/Pinball...