Class: Ruby2Faust::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/ruby2faust/ir.rb

Overview

Intermediate Representation node for DSP graphs. Nodes are immutable value objects representing DSP operations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, args: [], inputs: [], channels: 1) ⇒ Node

Returns a new instance of Node.



9
10
11
# File 'lib/ruby2faust/ir.rb', line 9

def initialize(type:, args: [], inputs: [], channels: 1)
  super(type: type, args: args.freeze, inputs: inputs.freeze, channels: channels)
end

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



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

def args
  @args
end

#channelsObject

Returns the value of attribute channels

Returns:

  • (Object)

    the current value of channels



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

def channels
  @channels
end

#inputsObject

Returns the value of attribute inputs

Returns:

  • (Object)

    the current value of inputs



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

def inputs
  @inputs
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



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

def type
  @type
end

Instance Method Details

#fingerprintObject



13
14
15
16
# File 'lib/ruby2faust/ir.rb', line 13

def fingerprint
  content = [type, args, inputs.map(&:fingerprint)].inspect
  Digest::SHA1.hexdigest(content)
end

#same_structure?(other) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ruby2faust/ir.rb', line 18

def same_structure?(other)
  fingerprint == other.fingerprint
end