Class: NewlineHw::GuiTrigger

Inherits:
Object
  • Object
show all
Defined in:
lib/newline_hw/gui_trigger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, config) ⇒ GuiTrigger

Returns a new instance of GuiTrigger.



9
10
11
12
# File 'lib/newline_hw/gui_trigger.rb', line 9

def initialize(data, config)
  @newline_submission_id = data["id"]
  @application = config.terminal
end

Instance Attribute Details

#editorObject (readonly)

Returns the value of attribute editor.



8
9
10
# File 'lib/newline_hw/gui_trigger.rb', line 8

def editor
  @editor
end

Instance Method Details

#applicationObject



14
15
16
17
# File 'lib/newline_hw/gui_trigger.rb', line 14

def application
  return "Terminal".freeze unless %w(iTerm2 Terminal).include?(@application)
  @application
end

#callObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/newline_hw/gui_trigger.rb', line 19

def call
  applescript = case application
                when "iTerm2"
                  applescript_for_iterm
                else
                  applescript_for_terminal
  end

  { terminal_output: `osascript -e '#{applescript}'` }
end