Last active
March 21, 2016 00:04
-
-
Save mindplace/2f279d031a58999a9cb8 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
| class Calculator | |
| extend ExtraArrayMethods | |
| def self.method_missing(method, *nums) | |
| operators = {add: :+, subtract: :-, multiply: :*, divide: :/} | |
| if operators.keys.include?(method) | |
| nums.inject(operators[method]) | |
| else | |
| "Sorry, '#{method.to_s}' method not available!" | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment