Need help to make the require-relative path expression

Hi,

Suppose I do have FS as below :

foo (b.rb)
|–bar
|–baz (a.rb)

Now in side the program a.rb I want to include the code b.rb. How to
write the require-relative expression?

Thanks

require-relative ‘…/…/b’

or

require-relative ‘…/…/b.rb’

Follow the code below :

FILE # => “home/kirti/Ruby/test.rb”

p File.expand_path(’./so.rb’,FILE)
p File.expand_path(’…/so.rb’,FILE)
p File.expand_path(’~/so.rb’,FILE)

output

“/home/kirti/Ruby/test.rb/so.rb”
“/home/kirti/Ruby/so.rb”
“/home/kirti/so.rb”

My understanding :

(a) “/home/kirti/Ruby/test.rb/so.rb”

File.expand_path(’./so.rb’,FILE) produces something like
home/kirti/Ruby/test.rb/./so.rb. Now as . means current directory,so
the above code produced.

(b) “/home/kirti/Ruby/so.rb”

File.expand_path(’…/so.rb’,FILE) produces something like
home/kirti/Ruby/test.rb/…/so.rb. Now as .. means go to parent
directory,so the above code produced,by dropping test.rb.

© “/home/kirti/so.rb”

File.expand_path(’~/so.rb’,FILE) produces something like
home/kirti/Ruby/test.rb/~/so.rb. Now as ~ means go to home
directory,so the above code produced,by adding the so.rb after home
directory.

Is my understanding of rules applied to 3 different cases are correct?
If not please correct me…