Class: Motion::Screenshots::Base

Inherits:
KSScreenshotManager show all
Defined in:
lib/motion/motion-screenshots.rb

Constant Summary collapse

SCREENSHOTS_BASE_FOLDER =
"motion_screenshots"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#group_by_blockObject

Returns the value of attribute group_by_block.



37
38
39
# File 'lib/motion/motion-screenshots.rb', line 37

def group_by_block
  @group_by_block
end

#screenshot_groupsObject

Returns the value of attribute screenshot_groups.



37
38
39
# File 'lib/motion/motion-screenshots.rb', line 37

def screenshot_groups
  @screenshot_groups
end

Class Method Details

.async_screenshot(title, &block) ⇒ Object



19
20
21
# File 'lib/motion/motion-screenshots.rb', line 19

def async_screenshot(title, &block)
  shared.async_screenshot(title, &block)
end

.group_by(&block) ⇒ Object

Adds a namespace folder for this screenshot class



15
16
17
# File 'lib/motion/motion-screenshots.rb', line 15

def group_by(&block)
  shared.group_by_block = block
end

.screenshot(title, &block) ⇒ Object



23
24
25
# File 'lib/motion/motion-screenshots.rb', line 23

def screenshot(title, &block)
  shared.screenshot(title, &block)
end

.start!Object



27
28
29
# File 'lib/motion/motion-screenshots.rb', line 27

def start!
  shared.start!
end

Instance Method Details

#async_screenshot(title, &block) ⇒ Object



50
51
52
# File 'lib/motion/motion-screenshots.rb', line 50

def async_screenshot(title, &block)
  @screenshot_groups << ScreenshotGroup.new(title, true, self, &block)
end

#group_by(&block) ⇒ Object



46
47
48
# File 'lib/motion/motion-screenshots.rb', line 46

def group_by(&block)
  @group_by_block = block
end

#initObject



39
40
41
42
43
44
# File 'lib/motion/motion-screenshots.rb', line 39

def init
  super
  @group_by_block = nil
  @screenshot_groups = []
  self
end

#screenshot(title, &block) ⇒ Object



54
55
56
# File 'lib/motion/motion-screenshots.rb', line 54

def screenshot(title, &block)
  @screenshot_groups << ScreenshotGroup.new(title, false, self, &block)
end

#setupScreenshotActionsObject



58
59
60
61
62
# File 'lib/motion/motion-screenshots.rb', line 58

def setupScreenshotActions
  @screenshot_groups.each do |sg|
    addScreenshotAction sg.to_KSScreenshotAction
  end
end

#start!Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/motion/motion-screenshots.rb', line 64

def start!
  return if @started

  @started = true

  @documents_path = String.new(NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0])
  screenshot_path = File.join(@documents_path, SCREENSHOTS_BASE_FOLDER)
  screenshot_path = File.join(screenshot_path, group_by_block.call) if @group_by_block
  self.screenshotsURL = NSURL.fileURLWithPath(screenshot_path)

  takeScreenshots
end