Class: MachineHead::Device

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = 'FFFFFFFF') ⇒ Device

Returns a new instance of Device.



5
6
7
8
9
# File 'lib/machine_head/device.rb', line 5

def initialize(id='FFFFFFFF')
  @id = id

  @tuners = [Tuner.new(self, 0), Tuner.new(self, 1)].freeze
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/machine_head/device.rb', line 3

def id
  @id
end

#tunersObject (readonly)

Returns the value of attribute tuners.



3
4
5
# File 'lib/machine_head/device.rb', line 3

def tuners
  @tuners
end

Class Method Details

.discoverObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/machine_head/device.rb', line 25

def self.discover
  devices = []

  `#{TOOL_PATH} discover`.each_line do |line|
    device = line.match(/^hdhomerun device ([0-9A-F]{8}) found/)
    devices << self.new(device[1]) if device
  end

  devices
end

Instance Method Details

#get(command) ⇒ Object



11
12
13
# File 'lib/machine_head/device.rb', line 11

def get(command)
  `#{TOOL_PATH} #{id} get #{command}`
end

#set(command, data) ⇒ Object



15
16
17
# File 'lib/machine_head/device.rb', line 15

def set(command, data)
  `#{TOOL_PATH} #{id} set #{command} #{data}`
end