Class: ViewServer::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/view_server/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.serve(port) ⇒ Object



25
26
27
28
29
# File 'lib/view_server/server.rb', line 25

def self.serve(port)
  DRb.start_service "druby://localhost:#{port}", Server.new
  puts DRb.uri
  DRb.thread.join
end

Instance Method Details

#pasteObject

From clipboard



21
22
23
# File 'lib/view_server/server.rb', line 21

def paste # From clipboard
  `pbpaste`
end

#show(data, file_ext = 'txt') ⇒ Object

I wanted to use the display method but it conflicts with the Object#display method



7
8
9
10
11
12
13
14
# File 'lib/view_server/server.rb', line 7

def show(data, file_ext = 'txt')
  TmpFile.open("", "." + file_ext) do |a|
    a << data
    a.close
    `open #{a.path} `
    sleep 5 #We don't want to delete the file before it's loaded
  end
end

#to_cb(data) ⇒ Object

To clipboard



16
17
18
19
# File 'lib/view_server/server.rb', line 16

def to_cb(data) # To clipboard
  File.open("#{ENV['HOME']}/tmp/clipboard", "w"){|a| a << data}
  IO.popen('pbcopy', 'w'){|a| a << data}
end