Skip to content

Instantly share code, notes, and snippets.

@murajun1978
Created May 23, 2014 14:44
Show Gist options
  • Save murajun1978/5d6d714d24d94f8757e3 to your computer and use it in GitHub Desktop.
Save murajun1978/5d6d714d24d94f8757e3 to your computer and use it in GitHub Desktop.
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