Forum: Italian Ruby user group Date un'occhiata

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
136d8428fd5efba4c0a31e46491c013a?d=identicon&s=25 Alessandro Mazzone (alex89)
on 2009-01-24 19:00
Devo tradurre una classeda php a ruby,ancora non ho finito la
traduzione,ma manca poco.Volevo chiedervi se nel passaggio a ruby ho
commesso errori di sintassi.

In PHP era questa:
if (!defined('__INCLUDE_PATH__'))
   define('__INCLUDE_PATH__', './');

require_once(__INCLUDE_PATH__.'webui.class.php');

class webui_project_tree extends webui {

   function __construct() {
      parent::__construct();
   }

   function __destruct() {
      parent::__destruct();
   }

   private function _generate_project_tree() {
      $node_list = array();
      if (isset($this->_project))
         if (is_array($this->_project))
            for ($i=0,$tot=count($this->_project); $i<$tot; $i++)
               $this->_project[$i]->get_info($node_list);
//       echo '<pre>'; print_r($node_list); echo '</pre>';
      return $node_list;
   }

   function webui_project_tree_str() {
      if
(!$this->is_cached('interface'.DIRECTORY_SEPARATOR.'webui_project_tree.tpl',
$status)) {
         $this->assign('project_tree', $this->_generate_project_tree());
      }
//       return
$this->fetch_template('interface'.DIRECTORY_SEPARATOR.'webui_project_tree.tpl',
$status, TFALSE, TRUE, -1);
      return
$this->fetch_template('interface'.DIRECTORY_SEPARATOR.'webui_project_tree.tpl',
$status, TRUE, FALSE, 0);
   }
}
// ~@:-]
?>

FINE PHP

TRADUZIONE:
require 'webui'

class Webui_project_tree < Webui
   def initialize ()
      super()
   end

  private

   def function_generate_project_tree
       node_list = array[]         #node_list variabile locale?
       i=0
      if (isset(self._project))             #equivalente di isset??
         if ((self._project).is_a?(Array))
         while i<(self._project).length
              self._project[i]self.(node_list).to_yaml    #corretto?????
              i=+1
       # puts '<pre>'; print_r($node_list); echo '</pre>';
            end
      return node_list
   end

   def function_webui_project_tree_str #questa è ancora quasi in PHP
      if
(!self.is_cached('interface'.DIRECTORY_SEPARATOR.'webui_project_tree.tpl',
$status))
         self.assign('project_tree', self._generate_project_tree())
      end
#       return
$this->fetch_template('interface'.DIRECTORY_SEPARATOR.'webui_project_tree.tpl',
$status, TFALSE, TRUE, -1);
      return
self.fetch_template('interface'.DIRECTORY_SEPARATOR.'webui_project_tree.tpl',
$status, TRUE, FALSE, 0)
   end
end
# ~@:-]
FINE CODICE

allora come sto procedendo?

Grazie
This topic is locked and can not be replied to.