Sha256: 55a653abc3a40b21ed6369789712d0bf1a109ec71077469e2bf3bba7659fc898

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

# coding: utf-8

# Clipboard is a centralized point to shell out to each individual platform's
# clipboard, pasteboard, or whatever they decide to call it.
#
module Boom
  class Clipboard
    class << self
      
      # Public: copies a given Item's value to the clipboard. This method is
      # designed to handle multiple platforms.
      #
      # Returns nothing.
      def copy(item)
        copy_command = 
          if RUBY_PLATFORM =~ /darwin/
            "pbcopy"
          else
            "xclip -selection clipboard"
          end

        `echo '#{item.value.gsub("\'","\\'")}' | tr -d "\n" | #{copy_command}`

        "Boom! We just copied #{item.value} to your clipboard."
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
boom-0.0.9 lib/boom/clipboard.rb
boom-0.0.8 lib/boom/clipboard.rb