Avatar of YANKAUSKAS
YANKAUSKASFlag for United States of America

asked on 

Ruby to Php

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!
PHP

Avatar of undefined
Last Comment
YANKAUSKAS
Avatar of double_helix
double_helix

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.
Avatar of YANKAUSKAS
YANKAUSKAS
Flag of United States of America image

ASKER

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 ?
Avatar of YANKAUSKAS
YANKAUSKAS
Flag of United States of America image

ASKER

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 ?
ASKER CERTIFIED SOLUTION
Avatar of YANKAUSKAS
YANKAUSKAS
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of YANKAUSKAS
YANKAUSKAS
Flag of United States of America image

ASKER

I did it by myself
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo