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.



441
442
443
444
445
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
# File 'lib/ruby-macrodroid/actions.rb', line 441

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



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/ruby-macrodroid/actions.rb', line 473

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