Class: TakeScreenshotAction

Inherits:
CameraAction show all
Defined in:
lib/ruby-macrodroid/actions.rb

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Action

#invoke

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(obj = nil) ⇒ TakeScreenshotAction

Returns a new instance of TakeScreenshotAction.



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/ruby-macrodroid/actions.rb', line 418

def initialize(obj=nil)
  
  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    
    e, macro = obj      
    
    a = [
      'Save to device', 
      'Send via email', 
      'Share via intent'
    ]
    
    s = e.text('item/description').to_s
    index = a.map(&:downcase).index s.downcase
  
    {option: index}
    
  end 
  
  options = {
    option: 0, 
    use_smtp_email: false, 
    mechanism_option: 0, 
    save_to_jpeg: false
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/ruby-macrodroid/actions.rb', line 450

def to_s(colour: false, indent: 0)
  
  @s = 'Take Screenshot' #+ @h.inspect
  
  options = [
    'Save to device', 
    'Send via email', 
    'Share via intent'
  ]
  
  option = options[@h[:option]]
  
  @s += "\n" + option
  super()
  
end