Class: IRB::Kit::Helpers::Clip
- Inherits:
-
HelperMethod::Base
- Object
- HelperMethod::Base
- IRB::Kit::Helpers::Clip
- Defined in:
- lib/irb/kit/helpers/clip.rb
Overview
Copies input to macOS clipboard.
Constant Summary collapse
- MONIKER =
:clip
Instance Method Summary collapse
- #execute(*lines) ⇒ Object
-
#initialize(io = IO) ⇒ Clip
constructor
A new instance of Clip.
Constructor Details
#initialize(io = IO) ⇒ Clip
Returns a new instance of Clip.
12 13 14 15 |
# File 'lib/irb/kit/helpers/clip.rb', line 12 def initialize io = IO super() @io = io end |
Instance Method Details
#execute(*lines) ⇒ Object
17 18 19 20 21 |
# File 'lib/irb/kit/helpers/clip.rb', line 17 def execute(*lines) io.popen("pbcopy", "w") { |clipboard| clipboard.write lines.join("\n") } rescue Errno::ENOENT "ERROR: Unable to copy since `pbcopy` is only supported on macOS." end |