Class: Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lockr/config.rb

Constant Summary collapse

CONFIG_FILE =
'.lockr'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lockr/config.rb', line 7

def initialize()
  @config = nil
  
  if File.exists?( CONFIG_FILE)
    File.open( CONFIG_FILE, 'r') do |f|
      @config = YAML::load(f)
    end
  else
    filename = File.expand_path("~/#{CONFIG_FILE}")
    if File.exists?( filename)
      File.open( filename, 'r') do |f|
        @config = YAML::load(f)
      end
    end
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/lockr/config.rb', line 5

def config
  @config
end