Created
October 24, 2008 17:01
-
-
Save jcoglan/19491 to your computer and use it in GitHub Desktop.
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
%w(+ -).each do |symbol| | |
Range.class_eval do | |
define_method symbol do |value| | |
x, y = [first, last].map { |x| x.send(symbol, value) } | |
x..y | |
end | |
end | |
end | |
%w(* / **).each do |symbol| | |
Range.class_eval do | |
define_method symbol do |value| | |
map { |x| x.send(symbol, value) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment