Created
July 14, 2014 21:42
-
-
Save rskvirskiy/0191b2bd52c3fa8205e2 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
| numbers = %w(zero one two three four five six seven eight nine) | |
| operations = { | |
| 'minus' => '-', | |
| 'plus' => '+', | |
| 'times' => '*', | |
| 'divided_by' => '/' | |
| } | |
| (0..9).each do |number| | |
| define_method numbers[number] do |proc = nil| | |
| return proc.call(number) if proc | |
| number | |
| end | |
| end | |
| operations.each do |key, value| | |
| define_method key do |number| | |
| Proc.new { |x| x.send(value, number.to_f) } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment