Class: AllSeeingPi::Golem

Inherits:
Object
  • Object
show all
Defined in:
lib/all_seeing_pi/golem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGolem

Returns a new instance of Golem.



8
9
10
11
# File 'lib/all_seeing_pi/golem.rb', line 8

def initialize
  @camera = AllSeeingPi::Camera.new
  @uploader = AllSeeingPi::Uploader.new
end

Instance Attribute Details

#cameraObject (readonly)

Returns the value of attribute camera.



6
7
8
# File 'lib/all_seeing_pi/golem.rb', line 6

def camera
  @camera
end

#uploaderObject (readonly)

Returns the value of attribute uploader.



6
7
8
# File 'lib/all_seeing_pi/golem.rb', line 6

def uploader
  @uploader
end

Instance Method Details

#report(msg) ⇒ Object



23
24
25
# File 'lib/all_seeing_pi/golem.rb', line 23

def report(msg)
  puts msg unless ENV['ALL_SEEING_PI_ENV'] == 'test'
end

#spyObject



13
14
15
16
17
18
19
20
21
# File 'lib/all_seeing_pi/golem.rb', line 13

def spy
  image_path = @camera.capture
  return unless File.exists?(image_path)

  report "Captured #{image_path}"

  store_image(image_path)
  FileUtils.rm(image_path)
end

#store_image(image_path) ⇒ Object



27
28
29
# File 'lib/all_seeing_pi/golem.rb', line 27

def store_image(image_path)
  @uploader.upload(image_path)
end