Class: Cejo::Ops::Brightness
- Inherits:
-
Object
- Object
- Cejo::Ops::Brightness
- Defined in:
- lib/cejo/ops/brightness.rb
Overview
Manage System brightness.
Constant Summary collapse
- STEP =
5
- BRIGHTER =
'brightnessctl'
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
- #action ⇒ Object
- #final_command ⇒ Object
-
#initialize(state) ⇒ Brightness
constructor
A new instance of Brightness.
- #run ⇒ Object
- #states ⇒ Object
Constructor Details
#initialize(state) ⇒ Brightness
Returns a new instance of Brightness.
12 13 14 |
# File 'lib/cejo/ops/brightness.rb', line 12 def initialize(state) @state = state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
10 11 12 |
# File 'lib/cejo/ops/brightness.rb', line 10 def state @state end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
10 11 12 |
# File 'lib/cejo/ops/brightness.rb', line 10 def step @step end |
Instance Method Details
#action ⇒ Object
23 24 25 |
# File 'lib/cejo/ops/brightness.rb', line 23 def action states[state.to_sym] end |
#final_command ⇒ Object
27 28 29 |
# File 'lib/cejo/ops/brightness.rb', line 27 def final_command "#{BRIGHTER} #{action}" end |
#run ⇒ Object
31 32 33 34 |
# File 'lib/cejo/ops/brightness.rb', line 31 def run @state = state.to_sym if %w[up down].include? state system action end |