Module: Patch::IO::OSC::Action

Extended by:
Action
Included in:
Action
Defined in:
lib/patch/io/osc/action.rb

Overview

Find and identify OSC Actions

Instance Method Summary collapse

Instance Method Details

#find_by_address(actions, address) ⇒ Hash

Find an action by its OSC address

Parameters:

  • actions (Array<Hash>)
  • address (String)

Returns:

  • (Hash)


30
31
32
33
34
35
# File 'lib/patch/io/osc/action.rb', line 30

def find_by_address(actions, address)
  osc_actions(actions).find do |action|
    regex = Regexp.new(action[:osc][:address])
    address.match(regex)
  end
end

#osc?(action) ⇒ Boolean

Is the given action OSC?

Parameters:

  • action (Hash)

Returns:

  • (Boolean)


15
16
17
# File 'lib/patch/io/osc/action.rb', line 15

def osc?(action)
  !action[:osc].nil?
end

#osc_actions(actions) ⇒ Array<Hash>

Filter the given actions only to return OSC actions

Parameters:

  • actions (Array<Hash>)

Returns:

  • (Array<Hash>)


22
23
24
# File 'lib/patch/io/osc/action.rb', line 22

def osc_actions(actions)
  actions.select { |action| osc?(action) }
end