[lnkForumImage]
TotalShareware - Download Free Software

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


 

zeeman11

3/2/2007 9:05:00 PM

Hi,

I'm using fxri and I have required a ruby file as follows:

require "c:\myWork\motor.rb"

My question is, how do I reload this file when I make changes?

Thanks.

5 Answers

Austin Ziegler

3/2/2007 9:30:00 PM

0

On 3/2/07, zeeman11@gmail.com <zeeman11@gmail.com> wrote:
> Hi,
>
> I'm using fxri and I have required a ruby file as follows:
>
> require "c:\myWork\motor.rb"

1. You don't generally want to use Windows-style paths at all.
2. You don't generally want to use absolute paths at all.
3. You don't generally want to use the .rb extension with #require.

> My question is, how do I reload this file when I make changes?

3. You want to #load the file, not #require the file. You MUST use the
rb extension with #load.

-austin
--
Austin Ziegler * halostatue@gmail.com * http://www.halo...
* austin@halostatue.ca * http://www.halo...feed/
* austin@zieglers.ca

zeeman11

3/2/2007 10:03:00 PM

0

Great, thanks.

Stefano Crocco

3/2/2007 10:04:00 PM

0

Alle venerdì 2 marzo 2007, zeeman11@gmail.com ha scritto:
> Hi,
>
> I'm using fxri and I have required a ruby file as follows:
>
> require "c:\myWork\motor.rb"
>
> My question is, how do I reload this file when I make changes?
>
> Thanks.

I assume you're speaking about the irb session embedded in fxri. If I'm wrong,
my answer won't be very useful.

I think the cleanest way to reload a file is to use the load method:

load 'c:\myWork\motor.rb'

(note that with load you need to specify the extension).
Different from require, load doesn't check whether the file already is in $"
(the list of required files), although this is not explicitly said in the ri
documentation, and can't load C extensions.

Another way to reload the file should be to remove it from $" and use require.

In both cases, you must be careful. Suppose the file a.rb contains the
following:

---File a.rb---

class C
def method1
"method1"
end

def method2
"method2"
end
end

In the interactive session, you do:

require 'a' #you could also do load 'a.rb'
c=C.new
c.method1
=> "method1"

c.method2
=> "method2"


Then you modify a.rb:

---File a.rb modified---
class C

def method2
"method2"
end

end #you removed the definition of method1

You go back to the interactive session and type

c.method2
=> "method2"

c.method1 #you'd expect a NoMethodError, since the method has been removed.
=> "method1"

c1=C.new #create a new instance of C using the last definition

c1.method1
=>NoMethodError

The point is that loading the file again doesn't clear whatever it was defined
in it the first time it was loaded. I think (but I'm only guessing) that
loading for a second time a file which contains a class or a module looks a
bit like (but it's different from) reopening the class or module. For
instance, if in the modified a.rb you'd added the line

undef_method :method1

inside the definition of C, then calling c.method1 would have raised a
NoMethodError.


I hope all this helps

Stefano

Y L. Blackwood

2/17/2013 12:26:00 AM

0

Yoorghis: Real name Gary Richard Roselles. Before he was exposed he
changed his name every few days or weeks mainly because he's a
sociopathic coward, a pussy, and above all else a LIAR and a
time-waster. Gary is another example of a Complete Loser: He is
festering away in a one-bedroom apartment on Medicaid and Social
Security having wasted his entire life...

Gary uses "X-No-Archive: yes" in his message Header to force
server-side deletion of ALL of his posts and this is usually the only
way to detect his presence (unless you detect the strong odor of
shit).

Note that when you reply to a Proven Liar you encourage them to
continue lying.

Gary Richard Roselles (68+)
Diane M Roselles (52+)
4215 Cedar Ridge Pl, Apt 42
Rapid City, SD 57702-3190
(605) 341-2445

[][][][][][]
The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

[Courtesy of Buster Norris]

On Wed, 13 Feb 2013 19:26:03 -0700, Yoorghis@Jurgis.net wrote:
>After December, 2002 (and after the Vote to authorize), Saddam allowed
>UNSCOM to inspect anytime, anyplace, anywhere

LIAR!!!!!!!!!!!!!!!!!!!!!!!!!

FBI reports describe Saddam Hussein's reasons for refusing UN
inspectors
http://www.guardian.co.uk/world/2009/jul/02/saddam-hussein-fbi...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

Yoorghis

2/17/2013 3:02:00 AM

0

On Sat, 16 Feb 2013 15:45:23 -0600, AlleyCat <alley@aohell.com> wrote:

>By the way, nerds... I'm not Wayback Jack. Check out his header, idiots.

Actually, by ANY name you're really not anything at all....