Class: Snapme::Snapper
- Inherits:
-
Object
- Object
- Snapme::Snapper
- Defined in:
- lib/snapme/snapper.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
readonly
Returns the value of attribute auth_token.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
Instance Method Summary collapse
- #auth_token_field_name ⇒ Object
- #endpoint_url ⇒ Object
- #file_field_name ⇒ Object
- #filename ⇒ Object
-
#initialize(host, interval, auth_token, command = ImagesnapCommand.new) ⇒ Snapper
constructor
A new instance of Snapper.
- #run(looping = true) ⇒ Object
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_token ⇒ Object (readonly)
Returns the value of attribute auth_token.
5 6 7 |
# File 'lib/snapme/snapper.rb', line 5 def auth_token @auth_token end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/snapme/snapper.rb', line 5 def command @command end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/snapme/snapper.rb', line 5 def host @host end |
#interval ⇒ Object (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_name ⇒ Object
27 28 29 |
# File 'lib/snapme/snapper.rb', line 27 def auth_token_field_name 'auth_token' end |
#endpoint_url ⇒ Object
23 24 25 |
# File 'lib/snapme/snapper.rb', line 23 def endpoint_url "#{host}/snapshot" end |
#file_field_name ⇒ Object
31 32 33 |
# File 'lib/snapme/snapper.rb', line 31 def file_field_name 'snapshot' end |
#filename ⇒ Object
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 |