Class: Motion::Screenshots::ScreenshotGroup

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

Instance Method Summary collapse

Constructor Details

#initialize(title, is_async, manager, &eval_block) ⇒ ScreenshotGroup

Returns a new instance of ScreenshotGroup.



79
80
81
82
83
84
85
86
# File 'lib/motion/motion-screenshots.rb', line 79

def initialize(title, is_async, manager, &eval_block)
  @title = title
  @is_async = is_async
  @manager = manager
  @before_actions = nil
  @after_actions = nil
  instance_eval(&eval_block) if eval_block
end

Instance Method Details

#after(&actions) ⇒ Object



92
93
94
# File 'lib/motion/motion-screenshots.rb', line 92

def after(&actions)
  @after_actions = actions
end

#before(&actions) ⇒ Object



88
89
90
# File 'lib/motion/motion-screenshots.rb', line 88

def before(&actions)
  @before_actions = actions
end

#ready!Object



96
97
98
99
100
101
102
103
104
# File 'lib/motion/motion-screenshots.rb', line 96

def ready!
  if @delay
    Dispatch::Queue.main.after(@delay.to_f) {
      @manager.actionIsReady
    }
  else
    @manager.actionIsReady
  end
end

#ready_delay(amount) ⇒ Object



106
107
108
# File 'lib/motion/motion-screenshots.rb', line 106

def ready_delay(amount)
  @delay = amount
end

#to_KSScreenshotActionObject



110
111
112
113
114
115
# File 'lib/motion/motion-screenshots.rb', line 110

def to_KSScreenshotAction
  KSScreenshotAction.actionWithName(@title, asynchronous: @is_async,
    actionBlock:-> { @before_actions.call if @before_actions },
    cleanupBlock: -> { @after_actions.call if @after_actions }
  )
end