class TakeScreenshotAction

Public Class Methods

new(obj=nil) click to toggle source
Calls superclass method CameraAction::new
# 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

Public Instance Methods

to_s(colour: false, indent: 0) click to toggle source
Calls superclass method MacroObject#to_s
# 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
Also aliased as: to_summary
to_summary(colour: false, indent: 0)
Alias for: to_s