Class: Amrita2::Filters::CommandFilter

Inherits:
Base show all
Defined in:
lib/amrita2/template.rb

Instance Attribute Summary

Attributes inherited from Base

#next_

Instance Method Summary collapse

Methods inherited from Base

filter_method, inherited, #parse_filter_a, #|

Constructor Details

#initialize(*args) ⇒ CommandFilter

Returns a new instance of CommandFilter.



2564
2565
2566
2567
2568
# File 'lib/amrita2/template.rb', line 2564

def initialize(*args)
  @args = args.collect do |a|
    a.inspect
  end.join(' ')
end

Instance Method Details

#define_element_method(de, cg, &block) ⇒ Object



2570
2571
2572
2573
2574
2575
2576
2577
# File 'lib/amrita2/template.rb', line 2570

def define_element_method(de, cg, &block)
  super do
    block.call
    cg.code "pipe = IO.popen(#@args, 'r+')"
    cg.code "pipe.write __stream__; pipe.close_write"
    cg.code "__stream__ = pipe.read ; pipe.close "
  end
end