Class: TryRb::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/tryrb/config.rb

Constant Summary collapse

FILE_NAME =
'.tryrbrc'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



15
16
17
18
# File 'lib/tryrb/config.rb', line 15

def initialize
  @path = File.join(File.expand_path('~'), FILE_NAME)
  @data = load_file
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/tryrb/config.rb', line 6

def path
  @path
end

Instance Method Details

#load_fileObject



26
27
28
29
30
31
# File 'lib/tryrb/config.rb', line 26

def load_file
  require 'yaml'
  YAML.load_file(@path)
rescue Errno::ENOENT
  default_config
end