Class: Datapimp::Sync::DropboxDelta

Inherits:
Object
  • Object
show all
Defined in:
lib/datapimp/sync/dropbox_delta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, cursor, path_prefix = nil) ⇒ DropboxDelta

Returns a new instance of DropboxDelta.



11
12
13
14
15
# File 'lib/datapimp/sync/dropbox_delta.rb', line 11

def initialize(client, cursor, path_prefix=nil)
  @client = client
  @cursor = cursor
  @path_prefix = path_prefix
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/datapimp/sync/dropbox_delta.rb', line 5

def client
  @client
end

#cursorObject

Returns the value of attribute cursor.



5
6
7
# File 'lib/datapimp/sync/dropbox_delta.rb', line 5

def cursor
  @cursor
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/datapimp/sync/dropbox_delta.rb', line 5

def data
  @data
end

#entriesObject

Returns the value of attribute entries.



5
6
7
# File 'lib/datapimp/sync/dropbox_delta.rb', line 5

def entries
  @entries
end

#path_prefixObject

Returns the value of attribute path_prefix.



5
6
7
# File 'lib/datapimp/sync/dropbox_delta.rb', line 5

def path_prefix
  @path_prefix
end

Instance Method Details

#_dropbox_delta(at = nil) ⇒ Object



28
29
30
31
32
33
# File 'lib/datapimp/sync/dropbox_delta.rb', line 28

def _dropbox_delta at=nil
  at ||= cursor
  response = client.delta(at, path_prefix)
  self.cursor = response["cursor"]
  response
end

#fetchObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/datapimp/sync/dropbox_delta.rb', line 42

def fetch
  return @response if @response

  response = _dropbox_delta

  if response["reset"] == true
    on_reset(path_prefix, cursor)
  end

  self.entries = {}.to_mash

  response["entries"].each do |entry|
    path, meta = entry
    self.entries[path] = meta
  end

  if response["has_more"] == true
    # TODO Implement
  end

  @response = response
end

#on_reset(path_prefix, cursor) ⇒ Object



39
40
# File 'lib/datapimp/sync/dropbox_delta.rb', line 39

def on_reset path_prefix, cursor
end

#processed!Object



17
18
19
20
# File 'lib/datapimp/sync/dropbox_delta.rb', line 17

def processed!
  # TODO
  # Should update cursor
end