Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created September 13, 2010 19:16
Show Gist options
  • Save francescoagati/577841 to your computer and use it in GitHub Desktop.
Save francescoagati/577841 to your computer and use it in GitHub Desktop.
an example of sourcify + php for generate php from a block
require 'rubygems'
require 'active_support'
require 'php'
require 'sourcify'
class Proc
def to_php
code=self.to_source.gsub("proc {","")[0..-2]
PHP.generate(code).to_php.gsub("<?php","")
end
end
proc1 = lambda do
$x + $y
def pippo(a)
return $a
end
end
puts proc1.to_php
#result -> $x + $y; function pippo($a) { return $a; };;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment