Ruby to Php

YANKAUSKAS
YANKAUSKAS used Ask the Experts™
on
hi guys,
I have an issue with translating ruby to php codes. This is web application. It used php codes (form) to get data. After people clicked Process button. Those data is inputted in ruby code through Post method. It calls main.ruby to process those data. In ruby codes, we had some classes ( different ruby files ) to manipulate data for example like verifying, exporting... data. After that data is render through ruby template (using rhtml and passed through cgi) to display final result in html files.
I am considering to use smarty template in php to translate those ruby code to php code. Can you suggest me some ideas how to deal with classes in ruby to translate it to classes in PHP code ?
and translate ruby templates (rhtml) to php using smarty templates ?
Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This is very much a case-by-case type situation, unfortunately however, there is currently no good automated way to convert Ruby to PHP, especially when you're talking about a templating system such as Smarty (which although is written in PHP, is actually an HTML template format with tags that Smarty converts into PHP commands for you).
The only guaranteed way to get working code out the PHP end of the equation is to find someone who knows both languages very well, and can convert your Ruby classes to PHP by hand.

There are plenty of sites that can convert the other way around. Perhaps some of these can help in fact.
This site: http://www.phptoruby.com/ specialises in comparing PHP functions to their equivalent functions in Ruby. Perhaps it can help you go the other way as well. All of their examples are very thorough in both languages.

I hope this helps somewhat.

Author

Commented:
I know then as i said  i must be convert it by myself try to convert Ruby classes to Php by hand.
But i  have a little bit  confuse about what i am going to deal with it as i mentioned earlier.
Any other suggestions ?

Author

Commented:
class Plate
   
  include Enumerable
 
  def initialize(rows, cols, opts={})  
    @plate = Array.new(rows){Array.new(cols)}
    @row_length = cols - 1
  end
 
  def [](row, col)
    @plate[row][col]
  end
 
  def []=(row, col, val)
    @plate[row][col] = val
  end
 
  def plate
    @plate
  end
 
  def each
    @plate.each {|row| row.each {|col| yield col } }
  end
 
  def each_with_coordinate
    @plate.each_with_index do |row, row_index|
      row.each_with_index do |col, col_index|
       yield row_index, col_index, @plate[row_index, col_index]
      end
    end
  end  
end
For example above this class. How can i convert it to php class ? I don't know whether Enumerable exist in php or not ?
I have finished it. Thanks.

Author

Commented:
I did it by myself

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial