Date un'occhiata


#1

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 ‘

’; print_r($node_list); echo ‘
’;
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 ‘

’; print_r($node_list); echo ‘
’;
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