class TOTP::CLI::Clipboard
Public Class Methods
set(text)
click to toggle source
# File lib/totp/cli/clipboard.rb, line 5 def set(text) if OS.mac? osx_copy(text) elsif OS.linux? linux_copy(text) else puts "Platform clipboard not supported" return end puts "Copied #{text} to clipboard" end
Private Class Methods
linux_copy(text)
click to toggle source
# File lib/totp/cli/clipboard.rb, line 24 def linux_copy(text) IO.popen('xsel -b', 'w') do |i| i << text end end
osx_copy(text)
click to toggle source
# File lib/totp/cli/clipboard.rb, line 20 def osx_copy(text) IO.popen('reattach-to-user-namespace pbcopy', 'w') { |i| i << text } end