Class: KeepAwakeAction
- Inherits:
-
ScreenAction
- Object
- MacroObject
- Action
- ScreenAction
- KeepAwakeAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Overview
Category: Screen
options:
keep awake, screen on => enabled: true
disable keep awake => enabled: false
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}) ⇒ KeepAwakeAction
constructor
A new instance of KeepAwakeAction.
- #to_s(colour: false) ⇒ Object
Methods inherited from Action
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ KeepAwakeAction
Returns a new instance of KeepAwakeAction.
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 |
# File 'lib/ruby-macrodroid/actions.rb', line 2145 def initialize(h={}) = { enabled: true, permanent: true, screen_option: 0, seconds_to_stay_awake_for: 0 } super(.merge h) end |
Instance Method Details
#to_s(colour: false) ⇒ Object
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 |
# File 'lib/ruby-macrodroid/actions.rb', line 2158 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\n " + screen + ' - ' + whenx else 'Disable Keep Awake' end end |