Module: Branch::Name::Clipable
- Included in:
- CLI
- Defined in:
- lib/branch/name/clipable.rb
Class Method Summary collapse
- .copy_to_clipboard(text) ⇒ Object
- .copy_to_clipboard_macos(text) ⇒ Object
- .copy_to_clipboard_windows(text) ⇒ Object
- .copy_to_clipboard_with(app:, text:) ⇒ Object
Class Method Details
.copy_to_clipboard(text) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/branch/name/clipable.rb', line 10 def copy_to_clipboard(text) if OS.mac? copy_to_clipboard_macos text true elsif OS.windows? copy_to_clipboard_windows text true else false end end |
.copy_to_clipboard_macos(text) ⇒ Object
22 23 24 |
# File 'lib/branch/name/clipable.rb', line 22 def copy_to_clipboard_macos(text) copy_to_clipboard_with(app: 'pbcopy', text: text) end |
.copy_to_clipboard_windows(text) ⇒ Object
26 27 28 |
# File 'lib/branch/name/clipable.rb', line 26 def copy_to_clipboard_windows(text) copy_to_clipboard_with(app: 'clip', text: text) end |
.copy_to_clipboard_with(app:, text:) ⇒ Object
30 31 32 |
# File 'lib/branch/name/clipable.rb', line 30 def copy_to_clipboard_with(app:, text:) IO.popen(app, 'w') { |pipe| pipe.puts text } end |