Class: Xrandr::Output
- Inherits:
-
Object
- Object
- Xrandr::Output
- Defined in:
- lib/xrandr.rb
Constant Summary collapse
- ON =
'on'.freeze
- OFF =
'off'.freeze
- DISCONNECTED =
'disconnected'.freeze
Instance Attribute Summary collapse
-
#connected ⇒ Object
readonly
Returns the value of attribute connected.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#modes ⇒ Object
readonly
Returns the value of attribute modes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#primary ⇒ Object
readonly
Returns the value of attribute primary.
-
#resolution ⇒ Object
readonly
Returns the value of attribute resolution.
-
#rotation ⇒ Object
readonly
Returns the value of attribute rotation.
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(name:, connected:, primary: false, resolution: nil, position: nil, rotation: '', info: '', dimensions: '', modes: []) ⇒ Output
constructor
A new instance of Output.
- #preferred ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(name:, connected:, primary: false, resolution: nil, position: nil, rotation: '', info: '', dimensions: '', modes: []) ⇒ Output
Returns a new instance of Output.
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/xrandr.rb', line 125 def initialize(name:, connected:, primary: false, resolution: nil, position: nil, rotation: '', info: '', dimensions: '', modes: []) raise ArgumentError, "must provide a name for the output" unless name raise ArgumentError, "connected cant be nil" unless connected == true || connected == false @name = name @connected = connected @primary = primary @resolution = resolution @position = position @info = info @rotation = rotation @dimensions = dimensions @modes = modes end |
Instance Attribute Details
#connected ⇒ Object (readonly)
Returns the value of attribute connected.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def connected @connected end |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def dimensions @dimensions end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def info @info end |
#modes ⇒ Object (readonly)
Returns the value of attribute modes.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def modes @modes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def name @name end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def position @position end |
#primary ⇒ Object (readonly)
Returns the value of attribute primary.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def primary @primary end |
#resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def resolution @resolution end |
#rotation ⇒ Object (readonly)
Returns the value of attribute rotation.
119 120 121 |
# File 'lib/xrandr.rb', line 119 def rotation @rotation end |
Instance Method Details
#current ⇒ Object
139 140 141 |
# File 'lib/xrandr.rb', line 139 def current modes.detect(&:current) end |
#preferred ⇒ Object
143 144 145 |
# File 'lib/xrandr.rb', line 143 def preferred modes.detect(&:preferred) end |
#status ⇒ Object
147 148 149 150 |
# File 'lib/xrandr.rb', line 147 def status return DISCONNECTED unless connected current ? ON : OFF end |