On Sun, Mar 22, 2009 at 9:32 AM, Daniel Dale <dochappy / gmail.com> wrote:

> I was told about Ruby several weeks ago and started my journey lol. I've
> read several tutorials but reading the tutorials I still couldn't grasp
> most of it and I thought  finding a  project I wanted to work on and
> just diving in might be the best bet.
>
> I want to create a program that I can enter  my game collection into.
> Ideally I want it to have a simple gui so others can  use it and  input
> their games as well.
>
> Here's the basic code I have  I keep getting an error stating
> uninitialized constant Game (NameError)
>
> code:
>
> class Game
>  def
>
> initialize(title,platform,genre,rating,published_by,developed_by,year,condition)
>  @title=title
>  @platform=platform
>  @genre=genre
>  @rating=rating
>  @published_by=published_by
>  @developed_by=developed_by
>  @year=year
>  @condition=condition
>  end
>
>  def to_s
>  "Games:
>
> #{@title}--#{@platform}--#{@genre}--#{@rating}--#{@published_by}--#(@developed_by)--#(@year)--#(@condition)"
>  end
> end
>
>
> game1=Game.new("FireProReturns","Playstation_2","Sports","Teen","Agetec_Inc.","Very_Good")
> game1.to_s
>
> Any help tips and etc on how to fix my problem and proceed will be
> greatly appreciated.
> --
> Posted via http://www.ruby-forum.com/.
>
> class Game
 def
initialize(title,platform,genre,rating,published_by,developed_by,year,condition)
 @title=title
 @platform=platform
 @genre=genre
 @rating=rating
 @published_by=published_by
 @developed_by=developed_by
 @year=year
 @condition=condition
 end

 def to_s
 puts "Games:
#{@title}--#{@platform}--#{@genre}--#{@rating}--#{@published_by}--#{@developed_by}--#{@year}--#{@condition}"
 end
end

game1=Game.new("FireProReturns","Playstation_2","Sports","Teen",
"Good","Agetec_Inc.","2000","Very_Good")
game1.to_s


Is what I'm guessing you should have.
You can put both of the methods in the same class.
You forgot the 'puts' before the Games: in the to_s method
Also uh to print a variable you have to have #{var} not #(var)
and when you had the game1=Game.new you were missing two of your arguments
hehe I just made them up.
And as Vikhyat said you needed to name the class Game for your
initialization to work or you can keep the class name Games but put the
other one to Games too.
Running the code above should give you

Games:
FireProReturns--Playstation_2--Sports--Teen--Good--Agetec_Inc.--2000--Very_Good

-- 
There was a man, they called him mad.
The more he gave, the more he had.