Class: Commandc::Text
- Inherits:
-
Object
- Object
- Commandc::Text
- Defined in:
- lib/commandc/text.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary collapse
- #copy ⇒ Object
- #escape_device_name(device_name) ⇒ Object
-
#initialize(text, device, open) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(text, device, open) ⇒ Text
Returns a new instance of Text.
9 10 11 12 13 |
# File 'lib/commandc/text.rb', line 9 def initialize(text, device, open) @text = text @device = escape_device_name(device) @open = open end |
Instance Attribute Details
#device ⇒ Object
7 8 9 |
# File 'lib/commandc/text.rb', line 7 def device @device end |
#open ⇒ Object
7 8 9 |
# File 'lib/commandc/text.rb', line 7 def open @open end |
#text ⇒ Object
7 8 9 |
# File 'lib/commandc/text.rb', line 7 def text @text end |
Instance Method Details
#copy ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/commandc/text.rb', line 15 def copy if open `open "command-c://x-callback-url/copyText?text=#{text}&deviceName=#{device}"` else `open "command-c://x-callback-url/copyAndOpenURL?url=#{text}&deviceName=#{device}"` end end |
#escape_device_name(device_name) ⇒ Object
23 24 25 |
# File 'lib/commandc/text.rb', line 23 def escape_device_name(device_name) URI.escape(device_name) end |