Class: RMonitor::Devices

Inherits:
Object
  • Object
show all
Extended by:
XRandRReadHelpers
Defined in:
lib/rmonitor/devices.rb

Class Method Summary collapse

Methods included from XRandRReadHelpers

collect_devices, extract_configuration, extract_configurations, extract_connected, extract_enabled, extract_name, extract_pos, split_blocks

Class Method Details

.parse(devices_data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rmonitor/devices.rb', line 7

def self.parse(devices_data)
  # Split the blocks of XRandR output
  blocks  = split_blocks(devices_data)

  # Filter out blocks that are not devices
  devices = collect_devices(blocks)

  # Create a data structure for each block
  devices.map! do |device|
    {
        :name           => extract_name(device),
        :pos            => extract_pos(device),
        :connected      => extract_connected(device),
        :enabled        => extract_enabled(device),
        :configuration  => extract_configuration(device),
        :configurations => extract_configurations(device),
    }
  end

  devices
end