Class: Workspace
Instance Method Summary
collapse
#config, #create?, #current_workspace, #notebook_exists?, #notebook_path, #notes_folder, #workspace_exists?, #workspace_path
Constructor Details
Returns a new instance of Workspace.
Instance Method Details
#create_note(notebook, title) ⇒ Object
10
11
12
|
# File 'lib/notes_cli/models/workspace.rb', line 10
def create_note(notebook, title)
NoteCreator.new(notebook, title, notebook_path(notebook), workspace_path).call
end
|
#delete_note(notebook, title) ⇒ Object
14
15
16
|
# File 'lib/notes_cli/models/workspace.rb', line 14
def delete_note(notebook, title)
NoteDeleter.new(notebook, title, notebook_path(notebook), workspace_path).call
end
|
#list_notes(notebook) ⇒ Object
18
19
20
|
# File 'lib/notes_cli/models/workspace.rb', line 18
def list_notes(notebook)
NoteLister.new(notebook).call
end
|
#switch(workspace) ⇒ Object
22
23
24
25
26
|
# File 'lib/notes_cli/models/workspace.rb', line 22
def switch(workspace)
return unless workspace_exists?(workspace) || create?('workspace')
update_entry('workspace', workspace)
end
|
#update_entry(key, value) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/notes_cli/models/workspace.rb', line 28
def update_entry(key, value)
current_config = config
current_config ? current_config[key] = value.strip.chomp : current_config = { key => value }
File.open(NotesCli::CONFIG_PATH, 'w') { |file| file.truncate(0) }
File.open(NotesCli::CONFIG_PATH, 'r+') do |f|
YAML.dump(current_config, f)
end
end
|