On Sat, Jan 2, 2016 at 9:53 PM, Nick Keighley
<
nick_keigh...@hotmail.com> wrote:
> On Fri, Jan 1, 2016 at 2:21 AM, Nick Keighley
> <
nick_keigh...@hotmail.com> wrote:
> On Saturday, 2 January 2016 01:56:54 UTC, Andras Suller wrote:
>
> this is specifically about ruboto running on an Android tablet
>
>>> Is it possible to put my source in a subdirectory of jruby/ ? And have
>>> the
>>> require calls work ?
>>>
>>> Of course I can put my files there but SCRIPTS in Ruboto IRB doesn't
>>> allow
>>> me to access them (in any obvious way)
>>>
>>> Even if I change the current directory in IRB (eg. "Dir.chdir 'subdir'")
>>> then "load 'myfile.rb'" it
>>> doesn't work. It says it can't find the file. OTH "load
>>> 'subdir/myfile.rb'"
>>> *does* work. But then requires in myfile.rb don't work. Again the file
>>> can't be found.
>
> this can be fixed by using
> require_relative './myfile2'
>
> But then I can't use the built in editor to edit scripts as it too only
> looks
> at ../jruby but not its subdirectories
When I used my tablet for ruby, I used VimTouch instead of the
built-in editor and executed the ruby scripts in a terminal emulator.
If you are new to programming, then you probably find Vim very hard to
use so this may not be suitable for you.
>
>> Then `load 'myfile.rb' ` should work.
>> I believe there is a way to set your work directory in Ruboto IRB, but
>> I cannot recall how.
>
> :-)
>
>> Is there any reason why you are using "load" instead of "require"? I
>> never seen anyone using "load" before.
>
> I'm brand new to Ruby (started learning it over the holiday) so I may indeed
> be doing very odd things. I am reading "Eloquent Ruby" so hopefully this
> will teach me idiomatic Ruby.
>
> I'm using "load" because, I understand, it loads unconditionally so If I
> change the source it will actually get reloaded. I understand "require"
> only loads stuff the first time.
It seems like "load" does not care about the $LOAD_PATH, you need to
use full path names.
Executing from a terminal reloads your ruby files, so you can use
"require". The downside is that you need to switch between the
terminal and the editor every time you want to execute your script (it
is easy with an external keyboard).
So as a workaround, I'd put everything in one ruby file. It would
solve the problem with the require/load and you could use the built-in
editor in Ruboto. Or use a laptop instead of a tablet :)
Cheers,
Andras