#######################类变量######################class Cloud @@count=0 def initialize(user,password,ip) @user = user @password =password @ip =ip end def createvm @ip =ip @@count+=1 endend##########################类方法和实例方法#########################class Example def instance_method puts "instance_method" end def Example.class_method puts "class class_method" endende1 = Example.new()e1.instance_methodclass MyLogger private_class_method :new @@logger = nil##类变量 def MyLogger.create @@logger = new unless @@logger @@logger end endend