Created
May 23, 2014 14:44
-
-
Save murajun1978/5d6d714d24d94f8757e3 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 Enemy | |
| def initialize | |
| @enemies = {} | |
| end | |
| def method_missing(method_name, *args) | |
| enemy = method_name.to_s | |
| if enemy =~ /=\z/ | |
| @enemies[enemy.chop] = args[0] | |
| else | |
| @enemise[enemy] | |
| end | |
| end | |
| end | |
| Enemy.new.instance_eval do | |
| name = "アボ" | |
| max_power = 1080000000 | |
| puts "name: #{name}" # => name: アボ | |
| puts "max power: #{max_power}" # => max power: 1080000000 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment