Class: OSCAccess::Analog::Output::Set
- Inherits:
-
Object
- Object
- OSCAccess::Analog::Output::Set
- Defined in:
- lib/osc-access/translate.rb
Instance Method Summary collapse
-
#initialize(from, to_set, options = {}) ⇒ Set
constructor
A new instance of Set.
- #process(input, options = {}) ⇒ Object
Constructor Details
#initialize(from, to_set, options = {}) ⇒ Set
Returns a new instance of Set.
83 84 85 86 |
# File 'lib/osc-access/translate.rb', line 83 def initialize(from, to_set, = {}) @from = from @to_set = to_set end |
Instance Method Details
#process(input, options = {}) ⇒ Object
88 89 90 91 92 |
# File 'lib/osc-access/translate.rb', line 88 def process(input, = {}) proportion = @from.numerator(input) / @from.denominator index = [((proportion * @to_set.size).to_i - 1), 0].max @to_set.at(index) end |