Created
May 10, 2013 17:08
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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