Class: Musicality::ValueComputer
- Inherits:
-
Function::Piecewise
- Object
- Function
- Function::Piecewise
- Musicality::ValueComputer
- Defined in:
- lib/musicality/notation/util/value_computer.rb
Overview
Given a start value, and value changes, compute the value at any offset.
Instance Attribute Summary collapse
-
#piecewise_function ⇒ Object
readonly
Returns the value of attribute piecewise_function.
Attributes inherited from Function::Piecewise
Attributes inherited from Function
Instance Method Summary collapse
-
#initialize(start_value, value_changes = {}) ⇒ ValueComputer
constructor
A new instance of ValueComputer.
Methods inherited from Function::Piecewise
#==, #add_piece, #at, #domain_include?
Methods inherited from Function
#==, #at, #sample, transform_domains
Constructor Details
#initialize(start_value, value_changes = {}) ⇒ ValueComputer
Returns a new instance of ValueComputer.
6 7 8 9 10 11 12 13 14 |
# File 'lib/musicality/notation/util/value_computer.rb', line 6 def initialize start_value, value_changes = {} super() set_default_value(start_value) if value_changes.any? value_changes.sort.each do |offset,change| add_change(offset, change) end end end |
Instance Attribute Details
#piecewise_function ⇒ Object (readonly)
Returns the value of attribute piecewise_function.
5 6 7 |
# File 'lib/musicality/notation/util/value_computer.rb', line 5 def piecewise_function @piecewise_function end |