Hey everyone
I’m just starting out with Ruby and I created a program to create and
manage a database of videogames with add, update, delete and list
functions. The commands create .txt logs in your temp folder, or
wherever you tell it to. It works great in the shell, but I’m trying to
translate it into a functional application within the Shoes GUI
For example, I tried to make Shoes read this:
class Update
def updateIT(games)
begin
ratings=Reporting.new
puts “Which game do you want to update?”
title = gets.chomp
if games[title.to_sym].nil?
puts “Game not found!”
else
puts “What’s the new rating? (Type a number 1 to 10)”
rating = gets.chomp
games[title.to_sym] = rating.to_i
logfile=ratings.createLog(“GamesUpdated”,“C:\temp\”)
ratings.reporting(logfile,"#{title} has been updated with a new
rating of #{rating} on ")
end
rescue
puts “Sorry, I didn’t understand that”
end
end
end
By turning it into this:
class Update
def updateIT(games,title,rating)
begin
reports=Reporting.new
newGames=Array.new
logfile=reports.createLog(“GamesUpdated”,“C:\temp\”)
reports.reporting(logfile,“#{title} has been updated with a new
rating of #{rating}”)
(games).each do |i|
item=“#{i}”.split(‘:’)
if(item[0]==“#{title}”)
newGames<<“#{title}: #{rating}”
puts “Successfully added #{title}: #{rating}”
else
newGames<<i
puts “Added #{i}.”
end # if statment
end # creating new array
puts “”
reports.reporting(logfile,“Old Games Listing & Ratings”)
(games).each do |i|
reports.reporting(logfile,“#{i}”)
end #OldGames logging
puts “”
reports.reporting(logfile,“New Games Listing & Ratings”)
(newGames).each do |i|
reports.reporting(logfile,“#{i}”)
end #newGames logging
return newGames
end
rescue
puts “Sorry, I didn’t understand that”
return games
end
end
end
This only one of the functions. Are there any Shoes aficionados willing
to help me figure this out? I’m currently in limbo between thinking
there’s not enough documentation on Shoes or that it just can’t be done
period
Here is what I have so far
http://tempsend.com/8560640248
and the original shell version