Linked Questions

0 votes
1 answer
75 views

How do I instantiate Foo from bar.rb? # foo.rb class Foo def initialize puts "foo" end end # bar.rb require 'foo' Foo.new $ ruby bar.rb /home/thufir/.rvm/rubies/ruby-2.4.1/lib/ruby/...
Thufir's user avatar
  • 8,575
1 vote
0 answers
46 views

I have a problem with require in my gem. When I user require in my main.rb like require 'folder/first' it throw error require': cannot load such file -- folder/first (LoadError) So my question is - ...
Dominik's user avatar
  • 111
51 votes
4 answers
91k views

For a while I had been including an entire class inside of a Ruby module. Apparently this is not what I am supposed to do. It appears that the point of a module is to store functions which can then be ...
user94154's user avatar
  • 16.6k
52 votes
4 answers
18k views

Is require File.expand_path(..., __FILE__) the best way to require other files within a project?
dan's user avatar
  • 46k
11 votes
3 answers
4k views

I have a folder full of ruby files, and when I try and require one file in another that is in the same directory using require 'file' I get a LoadError but when I use require './file' everything works ...
ab217's user avatar
  • 17.2k
3 votes
3 answers
3k views

Is there a way how to require all files in lib directory at once in irb console?: irb ( project root ) require './lib/' # not working structure . | --lib | |-- one.rb |-- two.rb |-- tree....
user avatar
5 votes
5 answers
792 views

This is a newbie question as I am attempting to learn Ruby by myself, so apologies if it sounds like a silly question! I am reading through the examples of why's (poignant) guide to ruby and am in ...
user avatar
3 votes
3 answers
1k views

Given that there is require_relative, which accepts relative as well as absolute paths, is there any reason to particularly use require, which accepts only absolute paths? Can all require be replaced ...
sawa's user avatar
  • 169k
2 votes
2 answers
2k views

How can I deploy a simple ruby script via homebrew? Here's what I tried Wrote formula in a GitHub repo named homebrew-foo # file https://github.com/foo/homebrew-foo/blob/master/foo.rb class Foo <...
american-ninja-warrior's user avatar
2 votes
2 answers
1k views

Going through "Well Grounded Rubyist" book and some code examples have you use require to load files. Unfortunately when using require "stacklike" I get this error "/home/userP/.rvm/rubies/ruby-2.0.0-...
Ordep81's user avatar
  • 1,127
0 votes
3 answers
604 views

I have two .rb files in the same directory samplecode.rb otherclass.rb here is the contents of SampleCode require 'otherclass' include OtherClass class SampleCode #... end and here is the ...
Alexander Mills's user avatar
0 votes
2 answers
1k views

I have written some classes and modules which I can include in my ruby scripts using require/require_relative. What we should include our scripts; classes or modules ? Does one has some benefit(s) ...
vikas027's user avatar
  • 5,842
-1 votes
2 answers
1k views

How can I navigate back one or multiple directories in Ruby? For example: users/luigi/test/folder/file.rb If I'm in the folder directory and want my file.rb script to load a file from within the ...
Luigi's user avatar
  • 5,663
0 votes
1 answer
823 views

I have a file 'page.rb' containing: require_relative "template.rb" class MM8 < Template end I then have a file 'template.rb' containing: class Template end Why can't I extend the MM8 class ...
Zach Smith's user avatar
  • 9,056
0 votes
1 answer
2k views

In Rails, there is a lib directory. It is not autoloaded by default. So when you load the Rails environment, all the modules and classes in this folder will not be known at runtime. I tried to ...
Daniel Viglione's user avatar

15 30 50 per page