Class: MIDIFX::Limit
- Inherits:
-
Object
- Object
- MIDIFX::Limit
- Defined in:
- lib/midi-fx/limit.rb
Instance Attribute Summary collapse
-
#limit_to ⇒ Object
(also: #range)
readonly
Returns the value of attribute limit_to.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
Instance Method Summary collapse
-
#initialize(property, limit_to, options = {}) ⇒ Limit
constructor
A new instance of Limit.
- #process(message) ⇒ Object
Constructor Details
#initialize(property, limit_to, options = {}) ⇒ Limit
8 9 10 11 12 |
# File 'lib/midi-fx/limit.rb', line 8 def initialize(property, limit_to, = {}) @limit_to = limit_to @property = property @name = [:name] end |
Instance Attribute Details
#limit_to ⇒ Object (readonly) Also known as: range
Returns the value of attribute limit_to.
5 6 7 |
# File 'lib/midi-fx/limit.rb', line 5 def limit_to @limit_to end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
5 6 7 |
# File 'lib/midi-fx/limit.rb', line 5 def property @property end |
Instance Method Details
#process(message) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/midi-fx/limit.rb', line 14 def process() val = .send(@property) if @limit_to.kind_of?(Range) .send("#{@property}=", @limit_to.min) if val < @limit_to.min .send("#{@property}=", @limit_to.max) if val > @limit_to.max elsif @limit_to.kind_of?(Numeric) .send("#{@property}=", @limit_to) end end |