Class: PM::Filter

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

Overview

Filters are blocks of code executed by a Connection to modify incoming MIDI bytes. Since we want to save them to files, we store the text representation as well.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code_chunk) ⇒ Filter

Returns a new instance of Filter.



10
11
12
# File 'lib/patchmaster/filter.rb', line 10

def initialize(code_chunk)
  @code_chunk = code_chunk
end

Instance Attribute Details

#code_chunkObject

Returns the value of attribute code_chunk.



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

def code_chunk
  @code_chunk
end

Instance Method Details

#call(conn, bytes) ⇒ Object



14
15
16
# File 'lib/patchmaster/filter.rb', line 14

def call(conn, bytes)
  @code_chunk.run(conn, bytes)
end

#to_sObject



18
19
20
# File 'lib/patchmaster/filter.rb', line 18

def to_s
  @code_chunk.text || '# no block text found'
end