Class: Snapme::Snapper

Inherits:
Object
  • Object
show all
Defined in:
lib/snapme/snapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, interval, auth_token, command = ImagesnapCommand.new) ⇒ Snapper

Returns a new instance of Snapper.



7
8
9
10
11
12
# File 'lib/snapme/snapper.rb', line 7

def initialize(host, interval, auth_token, command = ImagesnapCommand.new)
  @auth_token = auth_token
  @command    = command
  @host       = host
  @interval   = interval
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



5
6
7
# File 'lib/snapme/snapper.rb', line 5

def auth_token
  @auth_token
end

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/snapme/snapper.rb', line 5

def command
  @command
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/snapme/snapper.rb', line 5

def host
  @host
end

#intervalObject (readonly)

Returns the value of attribute interval.



5
6
7
# File 'lib/snapme/snapper.rb', line 5

def interval
  @interval
end

Instance Method Details

#auth_token_field_nameObject



27
28
29
# File 'lib/snapme/snapper.rb', line 27

def auth_token_field_name
  'auth_token'
end

#endpoint_urlObject



23
24
25
# File 'lib/snapme/snapper.rb', line 23

def endpoint_url
  "#{host}/snapshot"
end

#file_field_nameObject



31
32
33
# File 'lib/snapme/snapper.rb', line 31

def file_field_name
  'snapshot'
end

#filenameObject



35
36
37
# File 'lib/snapme/snapper.rb', line 35

def filename
  '/tmp/snapshot.jpg'
end

#run(looping = true) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/snapme/snapper.rb', line 14

def run(looping = true)
  loop do
    take_snapshot
    post_snapshot
    break unless looping
    sleep(interval)
  end
end