library, module, or...?

T

tony summerfelt

i have a class i'm working on:

class Myclass
def initialize()
end

def usefulmethod1()
end

def usefulmethod2()
end

it's currently over 100 lines and will probably be double that.

what's the most efficient way of turning that into a library or
module.

i'm guessing it can't be module because of the initialize method...
 
D

David A. Black

Hi --

i have a class i'm working on:

class Myclass
def initialize()
end

def usefulmethod1()
end

def usefulmethod2()
end

it's currently over 100 lines and will probably be double that.

what's the most efficient way of turning that into a library or
module.

i'm guessing it can't be module because of the initialize method...

Sure it can -- you just have to 'include' it in a class (i.e., you
can't instantiate the module, but you can still house an initialize
method in it for use by classes):

module M
def initialize
puts "hi"
end
end

class C
include M
end

C.new # => hi


David
 
T

tony summerfelt

Sure it can -- you just have to 'include' it in a class (i.e., you
can't instantiate the module, but you can still house an initialize
method in it for use by classes):

module M
def initialize
puts "hi"
end
end

class C
include M
end

C.new # => hi

ah, where to initialize everything that used to be in the class was
the missing piece of the puzzle for me...

the more i dig into ruby the more i like it...

according to the various things i've read via google, installing third
party modules should go into: site_ruby\1.8 ? that's what i'm
currently doing with my own code (although stuff i've installed has
gone lib\ruby\1.8

i want include a proper installer.rb/gui installer for my module
 
E

Eric Hodel

--Zlo2GrDIozf6aQFY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
according to the various things i've read via google, installing third
party modules should go into: site_ruby\1.8 ? that's what i'm
currently doing with my own code (although stuff i've installed has
gone lib\ruby\1.8

Look at setup.rb, you can find it here:

http://raa.ruby-lang.org/list.rhtml?name=3Dsetup

Also, look at RubyGems, since they seem to be up-and-coming RSN:

http://rubygems.rubyforge.org/wiki/wiki.pl
i want include a proper installer.rb/gui installer for my module

I don't believe a generic GUI installer has been created. Both setup.rb
and RubyGems can easily install your module.

--=20
Eric Hodel - (e-mail address removed) - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


--Zlo2GrDIozf6aQFY
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFAygE3MypVHHlsnwQRAludAJ0bGM8KrdAyONX+QApl8Ft2pc4xOACgnjPp
evuTUzn2zlkSSy6Ewx/NbDo=
=L4x1
-----END PGP SIGNATURE-----

--Zlo2GrDIozf6aQFY--
 
T

tony summerfelt

Look at setup.rb, you can find it here:

I don't believe a generic GUI installer has been created. Both setup.rb
and RubyGems can easily install your module.

will look at both of those. i was going to create both a windows
specific gui installer, but the more i think about it, anybody
programming in ruby is going to be familiar with the command line
anyway...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top