Class: KeepAwakeAction

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

Overview

Category: Screen

options:

keep awake, screen on => enabled: true
disable keep awake    => enabled: false

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #type

Instance Method Summary collapse

Methods inherited from Action

#invoke

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ KeepAwakeAction

Returns a new instance of KeepAwakeAction.



3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
# File 'lib/ruby-macrodroid.rb', line 3806

def initialize(h={})

  options = {
    enabled: true,
    permanent: true,
    screen_option: 0,
    seconds_to_stay_awake_for: 0
  }

  super(options.merge h)

end

Instance Method Details

#to_sObject



3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
# File 'lib/ruby-macrodroid.rb', line 3819

def to_s()
  
  screen = @h[:screen_option] == 0 ? 'Screen On' : 'Screen Off'
  
  if @h[:enabled] then
  
    whenx = if @h[:seconds_to_stay_awake_for] == 0 then
  
    'Until Disabled'
    
    else
      scnds = @h[:seconds_to_stay_awake_for]
      Subunit.new(units={minutes:60, hours:60}, seconds: scnds).strfunit("%x")
    end
    
    'Keep Device Awake ' + screen + ' ' + whenx
    
  else
    'Disable Keep Awake'
  end
  
  
end