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.
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(name:, connected:, primary: false, resolution: nil, position: nil, 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, info: '', dimensions: '', modes: []) ⇒ Output
Returns a new instance of Output.
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/xrandr.rb', line 120 def initialize(name:, connected:, primary: false, resolution: nil, position: nil, 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 @dimensions = dimensions @modes = modes end |
Instance Attribute Details
#connected ⇒ Object (readonly)
Returns the value of attribute connected.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def connected @connected end |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def dimensions @dimensions end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def info @info end |
#modes ⇒ Object (readonly)
Returns the value of attribute modes.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def modes @modes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def name @name end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def position @position end |
#primary ⇒ Object (readonly)
Returns the value of attribute primary.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def primary @primary end |
#resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
114 115 116 |
# File 'lib/xrandr.rb', line 114 def resolution @resolution end |
Instance Method Details
#current ⇒ Object
133 134 135 |
# File 'lib/xrandr.rb', line 133 def current modes.detect(&:current) end |
#preferred ⇒ Object
137 138 139 |
# File 'lib/xrandr.rb', line 137 def preferred modes.detect(&:preferred) end |
#status ⇒ Object
141 142 143 144 |
# File 'lib/xrandr.rb', line 141 def status return DISCONNECTED unless connected current ? ON : OFF end |