Several files and libraries

Load your own files with require_relative, and what Ruby offers without installing gems.

Runs in Zerethon IDE · Ruby 4.0 Official Ruby documentation ↗
main.rb
require_relative "geometry"

puts Geometry.area(3, 4)
puts Math.sqrt(16)
geometry.rb
module Geometry
  def self.area(width, height)
    width * height
  end
end

Output

12
4.0
Two files: main.rb (the entry, run by Run) and geometry.rb next to it.
  • require_relative "geometry" loads geometry.rb from the same folder as the current file; require_relative "lib/text" loads lib/text.rb.
  • require loads a library by name: json, csv, set, time, date, securerandom and the other default and bundled gems are available.
  • gem install and bundle install are not available: runs have no network and nothing is installed during a run.