Class: Nwcopy::Dropbox

Inherits:
Object
  • Object
show all
Defined in:
lib/nwcopy/dropbox.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.dropbox_baseObject

Returns the value of attribute dropbox_base.



6
7
8
# File 'lib/nwcopy/dropbox.rb', line 6

def dropbox_base
  @dropbox_base
end

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'lib/nwcopy/dropbox.rb', line 13

def self.available?
  return false unless File.exists? dropbox_dir

  unless File.exists? nwcopy_dir
    Dir.mkdir nwcopy_dir
  end

  File.exists? nwcopy_dir
end

.copy(io) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/nwcopy/dropbox.rb', line 23

def self.copy io
  clipboard = io.read
  digest = Digest::SHA1.hexdigest clipboard
  nwcopy_file = File.join nwcopy_dir, digest
  File.open(nwcopy_file, 'w+') do |f|
    f << clipboard
  end
  nwcopy_file
end

.paste(ignored = nil) ⇒ Object



38
39
40
# File 'lib/nwcopy/dropbox.rb', line 38

def self.paste ignored = nil
  latest_file.read
end

.timeObject

Used to determine which plugin has the newest file.



34
35
36
# File 'lib/nwcopy/dropbox.rb', line 34

def self.time
  latest_file ? latest_file.mtime : nil
end

.unavailable_messageObject



9
10
11
# File 'lib/nwcopy/dropbox.rb', line 9

def self.unavailable_message
  "Dropbox was not found at #{nwcopy_dir}. Get it at http://getdropbox.com/"
end