Class: Xrandr::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/xrandr.rb

Constant Summary collapse

ON =
'on'.freeze
OFF =
'off'.freeze
DISCONNECTED =
'disconnected'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, connected:, primary: false, resolution: nil, position: nil, rotation: '', info: '', dimensions: '', modes: []) ⇒ Output

Returns a new instance of Output.

Raises:

  • (ArgumentError)


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

#connectedObject (readonly)

Returns the value of attribute connected.



119
120
121
# File 'lib/xrandr.rb', line 119

def connected
  @connected
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



119
120
121
# File 'lib/xrandr.rb', line 119

def dimensions
  @dimensions
end

#infoObject (readonly)

Returns the value of attribute info.



119
120
121
# File 'lib/xrandr.rb', line 119

def info
  @info
end

#modesObject (readonly)

Returns the value of attribute modes.



119
120
121
# File 'lib/xrandr.rb', line 119

def modes
  @modes
end

#nameObject (readonly)

Returns the value of attribute name.



119
120
121
# File 'lib/xrandr.rb', line 119

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



119
120
121
# File 'lib/xrandr.rb', line 119

def position
  @position
end

#primaryObject (readonly)

Returns the value of attribute primary.



119
120
121
# File 'lib/xrandr.rb', line 119

def primary
  @primary
end

#resolutionObject (readonly)

Returns the value of attribute resolution.



119
120
121
# File 'lib/xrandr.rb', line 119

def resolution
  @resolution
end

#rotationObject (readonly)

Returns the value of attribute rotation.



119
120
121
# File 'lib/xrandr.rb', line 119

def rotation
  @rotation
end

Instance Method Details

#currentObject



139
140
141
# File 'lib/xrandr.rb', line 139

def current
  modes.detect(&:current)
end

#preferredObject



143
144
145
# File 'lib/xrandr.rb', line 143

def preferred
  modes.detect(&:preferred)
end

#statusObject



147
148
149
150
# File 'lib/xrandr.rb', line 147

def status
  return DISCONNECTED unless connected
  current ? ON : OFF
end