class X4ss
Public Class Methods
new(savefile=nil, mouse: false, window: false, debug: false)
click to toggle source
# File lib/x4ss.rb, line 14 def initialize(savefile=nil, mouse: false, window: false, debug: false) @file = savefile @count = 1 @mouse = mouse ? 'm' : '' @blob = [] @mode = window ? :window : :fullscreen @debug = debug end
Public Instance Methods
capture(mode=@mode)
click to toggle source
mode options: :window, :fullscreen
# File lib/x4ss.rb, line 27 def capture(mode=@mode) blob = screenshot(mode) if @file then File.write @file % @count, blob end @count += 1 @blob << blob end
from_blob()
click to toggle source
# File lib/x4ss.rb, line 42 def from_blob @blob end
record(interval: 1, duration: 6, mode: @mode) { |shift| ... }
click to toggle source
# File lib/x4ss.rb, line 46 def record(interval: 1, duration: 6, mode: @mode) return 'interval must be 0.8 or greater' if interval < 0.8 t = Time.now while(Time.now <= t+duration) do puts 'time: ' + Time.now.inspect @blob << screenshot(mode) sleep interval yield(@blob.shift) if block_given? end end
save(file=@file)
click to toggle source
# File lib/x4ss.rb, line 63 def save(file=@file) @blob.each.with_index {|blob, i| File.write file % (i+1).to_s, blob } :saved end
Private Instance Methods
screenshot(mode=@mode)
click to toggle source
# File lib/x4ss.rb, line 72 def screenshot(mode=@mode) area = mode == :fullscreen ? 'f' : 'w' `xfce4-screenshooter -c#{area}#{@mouse}` `xclip -selection clipboard -target image/png -out` end