Skip to content

Instantly share code, notes, and snippets.

@indirect
Created May 12, 2014 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indirect/0dafabf35dc520de4e93 to your computer and use it in GitHub Desktop.
Save indirect/0dafabf35dc520de4e93 to your computer and use it in GitHub Desktop.
Subclass proc to add a custom inspect method, add a class method to create a curried instance
class LessThanProc < Proc
attr_accessor :present
def self.with(present)
pv = Gem::Version.new(present.dup)
lt = self.new { |required| pv < Gem::Version.new(required) }
lt.present = present
return lt
end
def inspect
"\"=< #{present.to_s}\""
end
end
@indirect
Copy link
Author

Usage:

RSpec.configure do |c|
  c.filter_run_excluding :ruby => LessThanProc.new(RUBY_VERSION)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment