User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Ruby section within the Web Development category of DaniWeb, a massive community of 397,535 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,670 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !

My first Ruby programming question :-)

Join Date: Jul 2006
Posts: 155
Reputation: tefflox is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

My first Ruby programming question :-)

  #1  
Dec 26th, 2007
Hello, I'm pleased to be here by way of the html forum. I've been using php for static pages for 18 months. I wanted to learn rails, but I just realized that I could configure my host to automate index.rhtml files just like php. This is a major motivator for me to learn Ruby, and after a few more months I can start fresh with Rails. OK, here is the code that works in PHP, and what I've got so far in Ruby. The JS effect can be viewed here: http://listenlight.net/13 ---

<?php

  $i = 0; $n = 0;
  
  $str = "listenlightpoetryjournal";
  
  while( $str[$i] != "" ) {
    echo("<span id=\"n".$n++."\" style=\"position:relative; visibility: hidden; font-size: normal; top:".(rand(-18, 18))."px; color: black;\">".$str[$i]."</span>");
  
    $i++;
  }

  
?>


  <%   
  def banner
      str = "listenlightpoetryjournal"
      i, n = 0, 0
    until c = str[i] == nil 
        line = "<span id=\"n", n, "\" style=\"position: relative; font-size: normal; top:", rand(36) - 18, "px;\">", c, "</span>"
        i += 1
        n += 1 
        output = output, line
    end
  end
   %>
   
   <%= banner  %>

In the Ruby example, I've set the visibility attribute in the CSS, attempting to clean the markup. Also, is there a way to do a parallel incrementing?--such as a, b += 1, 1 (?)
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 2:51 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC