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, #siguid, #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.



4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
# File 'lib/ruby-macrodroid.rb', line 4543

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_s(colour: false) ⇒ Object



4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
# File 'lib/ruby-macrodroid.rb', line 4556

def to_s(colour: false)
  
  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