class QuiverToolbox::Notebook
Constants
- EXTENSION
- JSON_KEY_NAME
- JSON_KEY_UUID
- META_JSON_FILE
Attributes
file[RW]
name[RW]
store_path[RW]
uuid[RW]
Public Class Methods
new(attributes = nil) { |self| ... }
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 22 def initialize(attributes = nil) attributes.each do |k, v| instance_variable_set("@#{k}", v) end if attributes yield self if block_given? end
open(notebook_file)
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 9 def self.open(notebook_file) meta_json_file = File.join(notebook_file, META_JSON_FILE) meta_json = JSON.load(File.open(meta_json_file).read) new do |n| n.name = meta_json[JSON_KEY_NAME] n.uuid = meta_json[JSON_KEY_UUID] n.file = notebook_file end end
Public Instance Methods
build_note(note_hash)
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 77 def build_note(note_hash) note = QuiverToolbox::Note.new(note_hash) note.notebook_path = file_with_path note end
file_with_path()
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 45 def file_with_path @file_with_path ||= File.join("#{store_path}", file) end
meta_json_file()
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 50 def meta_json_file @meta_json_file ||= File.join(file_with_path, "meta.json") end
meta_json_hash()
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 55 def meta_json_hash { 'name' => @name, 'uuid' => @uuid } end
meta_json_string()
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 63 def meta_json_string JSON.pretty_generate(meta_json_hash) end
store()
click to toggle source
# File lib/quiver_toolbox/notebook.rb, line 68 def store FileUtils.mkdir_p(file_with_path) File.open(meta_json_file, 'w') do |f| f.puts meta_json_string end self end