Created
May 12, 2014 08:34
-
-
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
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: