Class: Commandc::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/commandc/text.rb

Overview

Since:

  • since 0.0.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, device, open) ⇒ Text

Returns a new instance of Text.

Since:

  • since 0.0.1



9
10
11
12
13
# File 'lib/commandc/text.rb', line 9

def initialize(text, device, open)
  @text = escape(text)
  @device = escape(device)
  @open = open
end

Instance Attribute Details

#deviceObject

Since:

  • since 0.0.1



7
8
9
# File 'lib/commandc/text.rb', line 7

def device
  @device
end

#openObject

Since:

  • since 0.0.1



7
8
9
# File 'lib/commandc/text.rb', line 7

def open
  @open
end

#textObject

Since:

  • since 0.0.1



7
8
9
# File 'lib/commandc/text.rb', line 7

def text
  @text
end

Instance Method Details

#copyObject

Since:

  • since 0.0.1



15
16
17
18
19
20
21
# File 'lib/commandc/text.rb', line 15

def copy
  if open
    `open "command-c://x-callback-url/copyAndOpenURL?url=#{text}&deviceName=#{device}"`
  else
    `open "command-c://x-callback-url/copyText?text=#{text}&deviceName=#{device}"`
  end
end

#escape(text_to_escape) ⇒ Object

Since:

  • since 0.0.1



23
24
25
# File 'lib/commandc/text.rb', line 23

def escape(text_to_escape)
  URI.escape(text_to_escape)
end