Class: MicroOSC::State
- Inherits:
-
Object
- Object
- MicroOSC::State
- Defined in:
- lib/micro-osc/state.rb
Constant Summary collapse
- Default =
{ :channel => 0, :octave => 2, :velocity => 100 }
Instance Attribute Summary collapse
-
#auto_output ⇒ Object
Returns the value of attribute auto_output.
-
#last_command ⇒ Object
readonly
Returns the value of attribute last_command.
-
#output_cache ⇒ Object
readonly
Returns the value of attribute output_cache.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#super_sticky ⇒ Object
Returns the value of attribute super_sticky.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ State
constructor
A new instance of State.
- #message_properties(opts, *props) ⇒ Object
- #record(m, a, b, outp) ⇒ Object
- #toggle_auto_output ⇒ Object
- #toggle_super_sticky ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ State
Returns a new instance of State.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/micro-osc/state.rb', line 20 def initialize( = {}) @auto_output = true @last_command = nil @super_sticky = false @channel = [:channel] || Default[:channel] @velocity = [:velocity] || Default[:velocity] @octave = [:octave] || Default[:octave] end |
Instance Attribute Details
#auto_output ⇒ Object
Returns the value of attribute auto_output.
13 14 15 |
# File 'lib/micro-osc/state.rb', line 13 def auto_output @auto_output end |
#last_command ⇒ Object (readonly)
Returns the value of attribute last_command.
17 18 19 |
# File 'lib/micro-osc/state.rb', line 17 def last_command @last_command end |
#output_cache ⇒ Object (readonly)
Returns the value of attribute output_cache.
17 18 19 |
# File 'lib/micro-osc/state.rb', line 17 def output_cache @output_cache end |
#pattern ⇒ Object
Returns the value of attribute pattern.
13 14 15 |
# File 'lib/micro-osc/state.rb', line 13 def pattern @pattern end |
#super_sticky ⇒ Object
Returns the value of attribute super_sticky.
13 14 15 |
# File 'lib/micro-osc/state.rb', line 13 def super_sticky @super_sticky end |
Instance Method Details
#message_properties(opts, *props) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/micro-osc/state.rb', line 45 def (opts, *props) output = {} props.each do |prop| output[prop] = opts[prop] self.send("#{prop.to_s}=", output[prop]) if !output[prop].nil? && (self.send(prop).nil? || @super_sticky) output[prop] ||= self.send(prop.to_s) end output end |
#record(m, a, b, outp) ⇒ Object
31 32 33 34 35 |
# File 'lib/micro-osc/state.rb', line 31 def record(m, a, b, outp) ts = now @output_cache << { :message => outp, :timestamp => ts } @last_command = { :method => m, :args => a, :block => b, :timestamp => ts } end |
#toggle_auto_output ⇒ Object
41 42 43 |
# File 'lib/micro-osc/state.rb', line 41 def toggle_auto_output @auto_output = !@auto_output end |
#toggle_super_sticky ⇒ Object
37 38 39 |
# File 'lib/micro-osc/state.rb', line 37 def toggle_super_sticky @super_sticky = !@super_sticky end |