lib/xrandr.rb in xrandr-0.0.2 vs lib/xrandr.rb in xrandr-0.0.3

- old
+ new

@@ -1,7 +1,7 @@ module Xrandr - VERSION = '0.0.2' + VERSION = '0.0.3' class Control attr_reader :screens, :outputs, :command def initialize(parser = Parser.new) @@ -110,10 +110,14 @@ end class Output attr_reader :name, :connected, :primary, :resolution, :position, :info, :dimensions, :modes + ON = 'on'.freeze + OFF = 'off'.freeze + DISCONNECTED = 'disconnected'.freeze + 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 @@ -129,9 +133,14 @@ modes.detect(&:current) end def preferred modes.detect(&:preferred) + end + + def status + return DISCONNECTED unless connected + current ? ON : OFF end end class Mode attr_reader :resolution, :rate, :current, :preferred