Forum: Ruby Translating Ruby program into Shoes GUI

E56b381a171c904e57af8f939f82fd55?d=identicon&s=25 Nephtiry B. (venusmizu24)
on 2014-08-15 01:01
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

http://tempsend.com/15FE4F47CC
Ccd9be37f5bd322e9d3968f767328928?d=identicon&s=25 Sebastjan H. (sebastjan_h)
on 2014-08-15 20:45
Hi,

I'd say it can be done. Which Shoes are you using?

I've downloaded your shoes version, but there's something off, since
most of the Shoes.app block is marked as string. I've fixed it and ran
it under green_shoes. The app window opened, but some buttons didn't
work or caused the app to crash. Unfortunately I can't go into details,
but at least for me it's difficult to just translate the whole app at
once.

As for the docs and help, there is a mailing list on [1] and guides can
be found [2].

If you're using green shoes, the manual is here [3]. Here [4] is one of
my apps in green shoes just as an example.

The latest version is Shoes4 though.

regards,
seba

[1] shoes@librelist.com
[2] http://shoesrb.com/tutorials.html
[3] https://ashbb.github.io/green_shoes/
[4] https://github.com/sebastjan-hribar/lang_cards
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.