SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My first ruby script got problem. EEEK!

    Hello all,

    I'm new here! I'm also very new to Ruby. Learning Ruby from the web from various sources.

    Anyway, I'm trying to practice some Ruby code, and so I wrote a small script. Though it's nothing special, but it's not working out. What my script does is to check to see if a directory is exist when a user enter a directory name -- then print something, if not then create a directory. Unfortunately, the directory got created but with a questionmark behind the directory. When trying to use Dir.delete, it's obvious that it's something wrong because the directory that the script just created won't be able to delete. It's all because of the directory got attached with a question mark makes it seems like it's a totally different directory. I don't get this! Anyway, I don't want to post the whole script here, but I attach the script at pastie[.]org/410753.

    Help anyone? Thanks...

  2. #2
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since no one answer me yet, but I asked around and got the solution

    puts is the opposite of chomp. I didn't use chomp, and that's why!

    Plus one of my other method see_me is not using ensure, and so the deleting process is not working too. After applying begin/ensure, I got the script to work!

    This thread can be closed now!

    Quote Originally Posted by arghagain View Post
    Hello all,

    I'm new here! I'm also very new to Ruby. Learning Ruby from the web from various sources.

    Anyway, I'm trying to practice some Ruby code, and so I wrote a small script. Though it's nothing special, but it's not working out. What my script does is to check to see if a directory is exist when a user enter a directory name -- then print something, if not then create a directory. Unfortunately, the directory got created but with a questionmark behind the directory. When trying to use Dir.delete, it's obvious that it's something wrong because the directory that the script just created won't be able to delete. It's all because of the directory got attached with a question mark makes it seems like it's a totally different directory. I don't get this! Anyway, I don't want to post the whole script here, but I attach the script at pastie[.]org/410753.

    Help anyone? Thanks...


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •