# Date un'occhiata

**URL:** <https://www.ruby-forum.com/t/date-unocchiata/158550>\
**Category:** IT\
**Created:** [January 24, 2009, 7:00pm UTC](https://www.ruby-forum.com/t/date-unocchiata/158550 "2009-01-24T19:00:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexpescara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@alexpescara](https://www.ruby-forum.com/u/alexpescara)\
**Post date:** [January 24, 2009, 7:00pm UTC](https://www.ruby-forum.com/t/date-unocchiata/158550/1 "2009-01-24T19:00:44Z")

</div>

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
