Class: Lerna::Display

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

Constant Summary collapse

INTERNAL_TYPES =
%w[ LVDS ]
DIGITAL_TYPES =
%w[ LVDS DP HDMI DVI ]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, connected) ⇒ Display

Returns a new instance of Display.

[View source]

11
12
13
14
# File 'lib/lerna/display.rb', line 11

def initialize(name, connected)
  @name = name
  @connected = connected
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.


16
17
18
# File 'lib/lerna/display.rb', line 16

def name
  @name
end

Class Method Details

.parse(line) ⇒ Object

[View source]

6
7
8
9
# File 'lib/lerna/display.rb', line 6

def self.parse(line)
  name, status, = line.split(/\s/)
  new(name, status == 'connected')
end

Instance Method Details

#==(other) ⇒ Object

[View source]

42
43
44
# File 'lib/lerna/display.rb', line 42

def ==(other)
  [name, connected?] == [other.name, other.connected?]
end

#analog?Boolean

Returns:

  • (Boolean)
[View source]

38
39
40
# File 'lib/lerna/display.rb', line 38

def analog?
  !digital?
end

#connected?Boolean

Returns:

  • (Boolean)
[View source]

18
19
20
# File 'lib/lerna/display.rb', line 18

def connected?
  @connected
end

#digital?Boolean

Returns:

  • (Boolean)
[View source]

34
35
36
# File 'lib/lerna/display.rb', line 34

def digital?
  DIGITAL_TYPES.include?(type)
end

#external?Boolean

Returns:

  • (Boolean)
[View source]

30
31
32
# File 'lib/lerna/display.rb', line 30

def external?
  !internal?
end

#internal?Boolean

Returns:

  • (Boolean)
[View source]

26
27
28
# File 'lib/lerna/display.rb', line 26

def internal?
  INTERNAL_TYPES.include?(type)
end

#typeObject

[View source]

22
23
24
# File 'lib/lerna/display.rb', line 22

def type
  name.sub(/-?\d+$/, '')
end