Class: Til::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/til/models/settings.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#settingsObject (readonly)

Returns the value of attribute settings.



5
6
7
# File 'lib/til/models/settings.rb', line 5

def settings
  @settings
end

#settings_file_pathObject (readonly)

Returns the value of attribute settings_file_path.



5
6
7
# File 'lib/til/models/settings.rb', line 5

def settings_file_path
  @settings_file_path
end

Class Method Details

.loadObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/til/models/settings.rb', line 7

def self.load
  @settings_file_path = File.expand_path("~/.til.config")
  if File.exist?(@settings_file_path)
    self.new(@settings_file_path)
  else
    puts "You don't appear to have a settings file! Configuring one now.".red
    Initializer.new.create_settings_file(@settings_file_path)
    self.new(@settings_file_path)
  end
end

Instance Method Details

#directoryObject



18
19
20
# File 'lib/til/models/settings.rb', line 18

def directory
  File.expand_path(settings["directory"])
end

#editorObject



26
27
28
# File 'lib/til/models/settings.rb', line 26

def editor
  settings["editor"] || ENV["VISUAL"] || ENV["EDITOR"] || "vim"
end

#github_repoObject



22
23
24
# File 'lib/til/models/settings.rb', line 22

def github_repo
  settings["github_repo"]
end