Class: David::Configure
- Inherits:
-
Object
- Object
- David::Configure
- Defined in:
- lib/david/configure.rb
Instance Attribute Summary collapse
-
#child_name ⇒ Object
readonly
Returns the value of attribute child_name.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#yaml ⇒ Object
readonly
Returns the value of attribute yaml.
Instance Method Summary collapse
-
#initialize ⇒ Configure
constructor
A new instance of Configure.
Constructor Details
#initialize ⇒ Configure
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_name ⇒ Object (readonly)
Returns the value of attribute child_name.
8 9 10 |
# File 'lib/david/configure.rb', line 8 def child_name @child_name end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
9 10 11 |
# File 'lib/david/configure.rb', line 9 def db @db end |
#yaml ⇒ Object (readonly)
Returns the value of attribute yaml.
8 9 10 |
# File 'lib/david/configure.rb', line 8 def yaml @yaml end |