Class: Xrandr::Control
- Inherits:
-
Object
- Object
- Xrandr::Control
- Defined in:
- lib/xrandr.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#screens ⇒ Object
readonly
Returns the value of attribute screens.
Instance Method Summary collapse
- #apply! ⇒ Object
- #configure(output = nil, **options) ⇒ Object
- #find_output(output) ⇒ Object (also: #[])
-
#initialize(parser = Parser.new) ⇒ Control
constructor
A new instance of Control.
Constructor Details
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/xrandr.rb', line 5 def command @command end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
5 6 7 |
# File 'lib/xrandr.rb', line 5 def outputs @outputs end |
#screens ⇒ Object (readonly)
Returns the value of attribute screens.
5 6 7 |
# File 'lib/xrandr.rb', line 5 def screens @screens end |
Instance Method Details
#apply! ⇒ Object
35 36 37 38 |
# File 'lib/xrandr.rb', line 35 def apply! Kernel.system(command) initialize end |
#configure(output = nil, **options) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/xrandr.rb', line 12 def configure(output = nil, **) output = find_output(output) if output command << " --output #{output.name}" if output command << .map do |option, value| value = nil if value == true " --#{option} #{value}".rstrip end.join(' ') end |
#find_output(output) ⇒ Object Also known as: []
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/xrandr.rb', line 22 def find_output(output) if output.kind_of? Output output elsif output.kind_of? String outputs.find {|o| o.name == output} elsif output.kind_of? Integer outputs[output] else raise ArgumentError, "Expecting a string, an integer or an Xrandr::Output instance" end end |