class Noteman::Dropbox::Node
We track folder state as a tree of Node
objects.
Attributes
content[RW]
path[RW]
Public Class Methods
from_json(jnode)
click to toggle source
# File lib/noteman/state.rb, line 46 def self.from_json(jnode) path, jcontent = jnode Node.new(path, Node.from_json_content(jcontent)) end
from_json_content(jcontent)
click to toggle source
# File lib/noteman/state.rb, line 57 def self.from_json_content(jcontent) if jcontent.is_a? Hash map_hash_values(jcontent) { |jchild| Node.from_json jchild } else jcontent end end
new(path, content)
click to toggle source
# File lib/noteman/state.rb, line 33 def initialize(path, content) # The "original" page (i.e. not the lower-case path) @path = path # For files, content is a pair (size, modified) # For folders, content is a hash of children Nodes, keyed by lower-case file names. @content = content end
to_json_content(content)
click to toggle source
# File lib/noteman/state.rb, line 50 def self.to_json_content(content) if content.is_a? Hash map_hash_values(content) { |child| child.to_json } else content end end
Public Instance Methods
folder?()
click to toggle source
# File lib/noteman/state.rb, line 40 def folder?() @content.is_a? Hash end
to_json()
click to toggle source
# File lib/noteman/state.rb, line 43 def to_json() [@path, Node.to_json_content(@content)] end