1 Replies - 857 Views - Last Post: 12 November 2011 - 12:23 PM Rate Topic: -----

Topic Sponsor:

#1 wiero  Icon User is offline

  • D.I.C Head

Reputation: 42
  • View blog
  • Posts: 77
  • Joined: 29-June 11

local code organisation

Posted 12 November 2011 - 05:20 AM

hi, i'm new to ruby and to learn it i try to solve problems from project euler
i wrote some 'extension' for integer and fibbonaci generator. for now i used require_local to include other files but it doesn't look well and i will create some other files.
What are the options to write some kind of local libraries and write one require?
Is This A Good Question/Topic? 0
  • +

Replies To: local code organisation

#2 Skaggles  Icon User is offline

  • the beared one
  • member icon


Reputation: 173
  • View blog
  • Posts: 570
  • Joined: 01-March 09

Re: local code organisation

Posted 12 November 2011 - 12:23 PM

You can use the keywords require and require_relative to require external files. Though, if you're looking at a way of including a whole collection of code files (like a code library) then one way of accomplishing this is to create what's called a Ruby gem. A gem is essentially packaged Ruby code that you can require into your application and utilize its classes and methods. One place to start is the RubyGems documentation.

What is a Gem?
Creating Your Own Gem
Gem Sawyer, Modern Day Ruby Warrior

This post has been edited by Skaggles: 12 November 2011 - 12:27 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1