Skip to content

Instantly share code, notes, and snippets.

@jcoglan
Created October 24, 2008 17:01
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 jcoglan/19491 to your computer and use it in GitHub Desktop.
Save jcoglan/19491 to your computer and use it in GitHub Desktop.
%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