Class: Snackhack2::ScreenShot
- Inherits:
-
Object
- Object
- Snackhack2::ScreenShot
- Defined in:
- lib/snackhack2/screenshots.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
Returns the value of attribute time.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
- #initialize ⇒ ScreenShot constructor
- #run ⇒ Object
Constructor Details
#initialize ⇒ ScreenShot
9 10 11 12 |
# File 'lib/snackhack2/screenshots.rb', line 9 def initialize @zip = 'screenshots.zip' @time = 60 end |
Instance Attribute Details
#time ⇒ Object
Returns the value of attribute time.
6 7 8 |
# File 'lib/snackhack2/screenshots.rb', line 6 def time @time end |
#zip ⇒ Object
Returns the value of attribute zip.
6 7 8 |
# File 'lib/snackhack2/screenshots.rb', line 6 def zip @zip end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/snackhack2/screenshots.rb', line 14 def run # creates a `.bat` filw with a command that will start the screen recordings File.open('lol.bat', 'w+') { |file| file.write("psr.exe /start /output #{@zip} /sc 1 /gui 0") } # this will save a .bat file that will stop the recording File.open('lol2.bat', 'w+') { |file| file.write('psr.exe /stop') } # run `lol.bat` Process.spawn('lol.bat') # sleeps for the amount of time declared in instance variable `@time` which by # defualt is 60 seconds sleep @time.to_i # runs lol2.bat system('lol2.bat') sleep 2 # deletes both `lol.bat` and `lol2.bat`. File.delete('lol.bat') File.delete('lol2.bat') end |