Guest User

Untitled

a guest
Apr 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. require 'YAML'
  2.  
  3. # Retains as a constant
  4. CONFIG = YAML.load_file('config.yml')
  5.  
  6. # or
  7. # Retains as an instance variable.
  8.  
  9. class Config
  10. def initialize(name)
  11. @config = get_from_disk(name)
  12. end
  13.  
  14. def get
  15. @config
  16. end
  17. private
  18. def get_from_disk(name)
  19. YAML.load_file(name)
  20. end
  21. end
  22.  
  23. config = Config.new('config.yml')
  24. config.get
Add Comment
Please, Sign In to add comment