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.



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/ruby-macrodroid/actions.rb', line 446

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



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/ruby-macrodroid/actions.rb', line 478

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