Class: Cejo::Ops::Brightness

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/ops/brightness.rb

Overview

Manage System brightness.

Constant Summary collapse

STEP =
5
BRIGHTER =
'brightnessctl'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stateObject (readonly)

Returns the value of attribute state.



10
11
12
# File 'lib/cejo/ops/brightness.rb', line 10

def state
  @state
end

#stepObject (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

#actionObject



23
24
25
# File 'lib/cejo/ops/brightness.rb', line 23

def action
  states[state.to_sym]
end

#final_commandObject



27
28
29
# File 'lib/cejo/ops/brightness.rb', line 27

def final_command
  "#{BRIGHTER} #{action}"
end

#runObject



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

#statesObject



16
17
18
19
20
21
# File 'lib/cejo/ops/brightness.rb', line 16

def states
  {
    up: "set #{STEP}%+",
    down: "set #{STEP}%-"
  }
end