fork download
  1. class Port
  2. attr_accessor :source, :target
  3. def initialize
  4. @source = Hash.new
  5. @source.instance_variable_set(:@port, self)
  6. @target = Hash.new
  7. def @source.[]=(key, value)
  8. if key == :precision
  9. @port.source[:offset] = 10
  10. end
  11. super
  12. end
  13.  
  14. end
  15.  
  16.  
  17. end
  18.  
  19. port = Port.new
  20. port.source[:precision] = 10
  21.  
  22. puts port.source[:precision]
  23. puts port.source[:offset]
Success #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
10
10