From: Ghislain Mary Date: 2005-06-07T05:54:58+09:00 Subject: Re: newbie read.scan (?) question Bruce D'Arcus a �crit : >>Why create an Article class and an Articles class? > > > Because I'm *real* newbie! My only programming background is with > XSLT. So I'm trying to also understand basic OO design in this > example. So welcome into the Ruby community ;-) I'm still considering myself as a newby too, and I don't often reply to posts on this list because I often think I am not able to contribute in a good way to the discussions. But I learn a lot by reading what is happening here :-) > Can you give me an abbreviated example of how to do actually do this? > For example, how do I define @@articles under the Article class, and > how would I then define the append method there. You could do something like: class Article include Journals attr_reader :title, :author, :description, :url # Create the Array containing the articles. @@articles = Array.new def initialize(title, author, url) @title, @author, @url = title, author, url # Add the new Article to the articles array. @@articles << self end def to_s "#@title, #@author" end def refer Journals::BASE_URL + "/" + @url + "&form=refer&file=file.txt" end def pdf Journals::BASE_URL + "/" + @url + "&form=pdf&file=file.pdf" end # Add a class method to get an Article by its index in the @@articles Array. def self.[](index) @@articles[index] end # Add a method to get the number of articles. # Call it how you want it to be called. def self.count @@articles.size end end Good luck, Ghislain