Sha256: 2e83065cfd554cc5de06186c7e61bb60217d8652acaf6e86cc3687ba31f70ac0

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

# 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.7 lib/boom/clipboard.rb
boom-0.0.6 lib/boom/clipboard.rb