Извините за вопрос новичка, но как мне передать/получить доступ к attar_accessor для нескольких классов и из них? в моем примере ниже класс Foo никогда не может видеть обновленные значения из класса Level.
class Level
attr_accessor :level, :speed
end
class Foo
attr_reader :a, :b
def initialize
@x = Level.new()
@a = @x.level
@b = @x.speed
end
def reload
@a = @x.level
@b = @x.speed
end
end
@testa = Foo.new()
@testb = Level.new()
@testb.level = 5
@testb.speed = 55
puts "Value for attr_accessor is:"
puts "#{@testb.level}"
puts "#{@testb.speed}"
puts "#{@testa.a}"
puts "#{@testa.b}"
@testa.reload
puts "#{@testa.a}"
puts "#{@testa.b}"