Last active
December 17, 2015 08:49
-
-
Save richo/5582441 to your computer and use it in GitHub Desktop.
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
def cmp(this, type=nil) | |
type ||= this.class | |
cmp_with_type(this, type) | |
end | |
def cmp_with_type(this, type) | |
if type == String | |
StringComparator.new(this) | |
elsif type == Fixnum or type == Bignum | |
NumberComparator.new(this) | |
else | |
raise "No comparator for #{type}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment