From: Ghislain Mary Date: 2005-06-07T04:34:56+09:00 Subject: Re: newbie read.scan (?) question Hi, Bruce D'Arcus a �crit : > Why if I dump my list of article objects to YAML, do I end up with > this: > > - !ruby/object:Article > author: > - > - "Hovorka, Alice J." > title: > - > - "The (Re) Production of Gendered Positionality in Botswana's > Commercial Urban > Agriculture Sector" > url: > http://journals.ohiolink.edu/cgi-bin/sciserv.pl?collection=journals&journal=00045608 > > I'm referring to the fact that article and title content aren't > represented the same as url (which is what I was expecting). Because your author and title probably aren't strings as you expect them to be but rather arrays. You should try to puts @title.inspect somewhere to see what it is. > I have these two classes: > > class Article > > include Journals > > attr_reader :title, :author, :description, :url > def initialize(title, author, url) > @title = title > @author = author > @url = url > end > > def to_s > "#@title, #@author" > end > > def abstract > # > end > > def refer > Journals::const_get(:BASE_URL) + "/" + > @url + "&form=refer&file=file.txt" > end > > def pdf > Journals::const_get(:BASE_URL) + "/" + > @url + "&form=pdf&file=file.pdf" > end > end > > class Articles > # > attr_reader :articles > > def initialize > @articles = Array.new > end > > def append(article) > @articles.push(article) > self > end > > def [](index) > @articles[index] > end > end Why create an Article class and an Articles class? You could make all the content of your Articles class also content of the Article class but at the class level instead of the instance level. So you just have to transform your @articles variable into @@articles and define your append and [] methods as self.append and self.[]. An other thing: I don't think you need to use Journals::const_get(:BASE_URL). You could simply use Journals::BASE_URL. HTH Ghislain