Ok ... I've googled this error and I see stome explanations about usnig destructive methods ...
I don't get it.
Consider
- - - -
class UD_Config
attr_accessor :container_list
attr_accessor :screen_x, :screen_y, :screen_width, :screen_height
@@config_filename = 'config.yml'
def initialize
debugger
if File.exists? @@config_filename
config_yaml_str = IO.read(@@config_filename)
self = YAML::load( config_yaml_str ) # This line seems to be the problem
else
set_defaults
end
end
def write_me
yaml_obj = YAML::dump( self )
File.open(filename,"w") { |f| f << yaml_obj }
end
private
# call this if there is no config file
def set_defaults
screen_x, screen_y, screen_width, screen_height = 30, 30, 600, 500
@container_list =
%w(
c:\abc\def.udd
d:\def\ghi.udd
f:\\ghi\jkl.udd
)
end
end
- - - -
I have been taught that "an object should take care of itself" ... what's the right way to do what I want?