Class: Commands::Screenshot

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/screenshot.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, settings) ⇒ Screenshot

Returns a new instance of Screenshot.



7
8
9
10
# File 'lib/commands/screenshot.rb', line 7

def initialize(args, settings)
  @api_root = settings.get('api_root')
  @file = Tempfile.new(['screenshot', '.jpg'])
end

Class Method Details

.matchesObject



26
27
28
# File 'lib/commands/screenshot.rb', line 26

def self.matches
  ['screenshot']
end

Instance Method Details

#goObject



12
13
14
15
16
# File 'lib/commands/screenshot.rb', line 12

def go
  `screencapture -t jpg -x #{@file.path}`
  response = RestClient.post "#{@api_root}/upload", file: File.new(@file.path, 'rb')
  @url = JSON.load(response)['url']
end

#media?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/commands/screenshot.rb', line 22

def media?
  true
end

#respondObject



18
19
20
# File 'lib/commands/screenshot.rb', line 18

def respond
  @url
end