Class: David::Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/david/configure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigure

Returns a new instance of Configure.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/david/configure.rb', line 11

def initialize
  Time.zone = 'Beijing'

  @config_dir = File.join(Dir.home, '.david')
  unless File.directory?(@config_dir)
    FileUtils.mkdir_p(@config_dir)
  end

  # default config file: ~/.david/config
  @config_file = File.join(@config_dir, 'config')
  @yaml = YAML.load File.read(@config_file)
  @child_name  = @yaml

  @db_file = File.join(@config_dir, "#{@child_name }.db")
  @db = SQLite3::Database.new @db_file
rescue
  init_profile
end

Instance Attribute Details

#child_nameObject (readonly)

Returns the value of attribute child_name.



8
9
10
# File 'lib/david/configure.rb', line 8

def child_name
  @child_name
end

#dbObject (readonly)

Returns the value of attribute db.



9
10
11
# File 'lib/david/configure.rb', line 9

def db
  @db
end

#yamlObject (readonly)

Returns the value of attribute yaml.



8
9
10
# File 'lib/david/configure.rb', line 8

def yaml
  @yaml
end