Skip to content

Instantly share code, notes, and snippets.

@hyeomans
Created May 10, 2013 17:08
Show Gist options
  • Save hyeomans/5555818 to your computer and use it in GitHub Desktop.
Save hyeomans/5555818 to your computer and use it in GitHub Desktop.
Using the block I can filter which operation I want to return with a simple string, otherwise it will return the 3 operations in an array.
require 'open3'
class PythonRegex
extend Open3
def self.calculate_intersection(first_regex, second_regex)
popen3('python', 'lib/services/greenery/main.py', first_regex, second_regex) do |stdin, stdout, stderr|
if block_given?
stdout.read.split("\n").select { |line| line.start_with? yield }
else
stdout.read.split("\n").each { |line| p line }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment