Class: Tipsy::Handler::PhpProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/tipsy/handler/php.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(d) ⇒ PhpProcessor

Returns a new instance of PhpProcessor.



25
26
27
# File 'lib/tipsy/handler/php.rb', line 25

def initialize(d)
  @data = d
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



23
24
25
# File 'lib/tipsy/handler/php.rb', line 23

def data
  @data
end

Instance Method Details

#renderObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tipsy/handler/php.rb', line 29

def render 
  file   = Tempfile.new("tipsy_php_#{Time.now.to_i}")
  result = ""
  begin
    file.write(@data)
    file.rewind
    result = `php #{file.path}`
  ensure
    file.close
    file.unlink
  end  
  result
end