Class: Gauge::GaugeScreenshot

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ GaugeScreenshot

Returns a new instance of GaugeScreenshot.



26
27
28
# File 'lib/gauge_screenshot.rb', line 26

def initialize
  @screenshots = []
end

Class Method Details

.instance ⇒ Object



30
31
32
# File 'lib/gauge_screenshot.rb', line 30

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

Instance Method Details

#capture ⇒ Object



34
35
36
# File 'lib/gauge_screenshot.rb', line 34

def capture
  @screenshots.push(capture_to_file)
end

#capture_to_file ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/gauge_screenshot.rb', line 38

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

#clear ⇒ Object



58
59
60
# File 'lib/gauge_screenshot.rb', line 58

def clear
  @screenshots = []
end

#get ⇒ Object



54
55
56
# File 'lib/gauge_screenshot.rb', line 54

def get
  @screenshots
end

#pending_screenshot ⇒ Object



48
49
50
51
52
# File 'lib/gauge_screenshot.rb', line 48

def pending_screenshot
  pending_screenshot = @screenshots
  clear
  pending_screenshot
end