Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # settings.rb
- # ------------
- # Get controller settings from file
- require 'yaml'
- require 'singleton' #Allows only one instance of the settings
- class Settings
- attr_accessor :current_objects
- include Singleton
- def initialize
- @current_objects = Array.new
- if File.exists?('./settings.yaml')
- #Open settings.yaml file if it exists and spit it into an Array/Hash Data Structure
- controller_settings = YAML.load(File.open( './settings.yaml' ))
- print "Success: Settings.yaml file available!\n"
- else
- print "Note: Default settings file doesn\'t exist. Creating..."
- #Create settings.yaml file
- File.new('./settings.yaml', 'w+').close
- print "Done!\n"
- end
- end
- def save
- ObjectSpace.each_object(Class) {|x|
- if x.to_s == "Ph"
- @current_objects << x
- print "Found object, " + x.inspect.to_s
- end
- }
- end
- end
Add Comment
Please, Sign In to add comment