Class: Commands::Picture

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

Constant Summary collapse

FILE_LOCATION =
"/tmp/tmp.jpg"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, settings) ⇒ Picture

Returns a new instance of Picture.



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

def initialize(args, settings)
  @api_root = settings.get('api_root')
end

Class Method Details

.matchesObject



25
26
27
# File 'lib/commands/picture.rb', line 25

def self.matches
  ['picture', 'snap']
end

Instance Method Details

#goObject



11
12
13
14
15
# File 'lib/commands/picture.rb', line 11

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

#media?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/commands/picture.rb', line 21

def media?
  true
end

#respondObject



17
18
19
# File 'lib/commands/picture.rb', line 17

def respond
  @url
end