Class: Oschii::OscMonitor
- Inherits:
-
Object
- Object
- Oschii::OscMonitor
- Defined in:
- lib/oschii/osc_monitor.rb
Constant Summary collapse
- COL_WIDTH =
40
Instance Attribute Summary collapse
-
#cloud ⇒ Object
readonly
Returns the value of attribute cloud.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #add(name, max: 100) ⇒ Object
-
#initialize(cloud) ⇒ OscMonitor
constructor
A new instance of OscMonitor.
- #render ⇒ Object
- #run ⇒ Object
- #sensor_bar(value) ⇒ Object
Constructor Details
#initialize(cloud) ⇒ OscMonitor
Returns a new instance of OscMonitor.
5 6 7 8 |
# File 'lib/oschii/osc_monitor.rb', line 5 def initialize(cloud) @cloud = cloud @values = {} end |
Instance Attribute Details
#cloud ⇒ Object (readonly)
Returns the value of attribute cloud.
10 11 12 |
# File 'lib/oschii/osc_monitor.rb', line 10 def cloud @cloud end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
10 11 12 |
# File 'lib/oschii/osc_monitor.rb', line 10 def values @values end |
Instance Method Details
#add(name, max: 100) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/oschii/osc_monitor.rb', line 12 def add(name, max: 100) unless values[name.to_sym] values[name.to_sym] = {value: nil, max: max} cloud.capture_osc name do |value| values[name.to_sym][:value] = value end end values[name.to_sym][:max] = max end |
#render ⇒ Object
35 36 37 38 39 40 |
# File 'lib/oschii/osc_monitor.rb', line 35 def render print "\r" values.each do |k, v| print (v) end end |
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/oschii/osc_monitor.rb', line 23 def run puts values.each do |k, v| print " #{k}".ljust (COL_WIDTH+4) end puts while true render sleep 0.01 end end |