Class: CanControlsGateway::OscToRcaDispatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ OscToRcaDispatcher

Returns a new instance of OscToRcaDispatcher.



10
11
12
13
14
15
# File 'lib/osc_to_rca_dispatcher.rb', line 10

def initialize data
  @raw_data    = data
  @osc_packet  = OSC::Packet.decode @raw_data rescue @osc_packet = nil
  @osc_message = @osc_packet[0][1] rescue @osc_message = nil
  @event       = extract_event @osc_message
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



8
9
10
# File 'lib/osc_to_rca_dispatcher.rb', line 8

def event
  @event
end

#osc_messageObject (readonly)

Returns the value of attribute osc_message.



8
9
10
# File 'lib/osc_to_rca_dispatcher.rb', line 8

def osc_message
  @osc_message
end

#osc_packetObject (readonly)

Returns the value of attribute osc_packet.



8
9
10
# File 'lib/osc_to_rca_dispatcher.rb', line 8

def osc_packet
  @osc_packet
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



8
9
10
# File 'lib/osc_to_rca_dispatcher.rb', line 8

def raw_data
  @raw_data
end

Instance Method Details

#dispatch_rcaObject



17
18
19
20
21
22
23
24
25
# File 'lib/osc_to_rca_dispatcher.rb', line 17

def dispatch_rca
  return true if @event.nil?
  my_args = { 'action' => @event }
  Ccg.logger.info "OscToRcaDispatcher: sending command : rci_uri: #{STATION['rci_uri']}, target: #{STATION['target']}, args: #{my_args.inspect}"
  my_command = CanControlsGateway::RcaCommand.new STATION['rci_uri'],
                                                  STATION['target'],
                                                  my_args
  Ccg.logger.info my_command.send_command
end