Class: Gauge::GaugeScreenshot

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGaugeScreenshot

Returns a new instance of GaugeScreenshot.



15
16
17
# File 'lib/gauge_screenshot.rb', line 15

def initialize
  @screenshots = []
end

Class Method Details

.instanceObject



19
20
21
# File 'lib/gauge_screenshot.rb', line 19

def self.instance
  @gauge_screenshots ||= GaugeScreenshot.new
end

Instance Method Details

#captureObject



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

def capture
  @screenshots.push(capture_to_file)
end

#capture_to_fileObject



27
28
29
30
31
32
33
34
35
# File 'lib/gauge_screenshot.rb', line 27

def capture_to_file
  unless Configuration.instance.screenshot_writer?
    content = Configuration.instance.screengrabber.call
    file_name = Util.unique_screenshot_file
    File.write(file_name, content)
    return File.basename(file_name)
  end
  Configuration.instance.screengrabber.call
end

#clearObject



47
48
49
# File 'lib/gauge_screenshot.rb', line 47

def clear
  @screenshots = []
end

#getObject



43
44
45
# File 'lib/gauge_screenshot.rb', line 43

def get
  @screenshots
end

#pending_screenshotObject



37
38
39
40
41
# File 'lib/gauge_screenshot.rb', line 37

def pending_screenshot
  pending_screenshot = @screenshots
  clear
  pending_screenshot
end