Class: Voicemeeter::Events::Tracker
- Inherits:
-
Object
- Object
- Voicemeeter::Events::Tracker
- Includes:
- Logging
- Defined in:
- lib/voicemeeter/event.rb
Instance Method Summary collapse
- #add(events) ⇒ Object
- #any? ⇒ Boolean
- #get ⇒ Object
- #info(msg = nil) ⇒ Object
-
#initialize(**kwargs) ⇒ Tracker
constructor
A new instance of Tracker.
- #remove(events) ⇒ Object
- #to_s ⇒ Object
Methods included from Logging
Constructor Details
#initialize(**kwargs) ⇒ Tracker
Returns a new instance of Tracker.
45 46 47 48 49 |
# File 'lib/voicemeeter/event.rb', line 45 def initialize(**kwargs) kwargs.each do |key, value| instance_variable_set("@#{key}", value || false) end end |
Instance Method Details
#add(events) ⇒ Object
73 74 75 76 |
# File 'lib/voicemeeter/event.rb', line 73 def add(events) events = [events] unless events.respond_to? :each events.each { |e| send("#{e}=", true) } end |
#any? ⇒ Boolean
69 70 71 |
# File 'lib/voicemeeter/event.rb', line 69 def any? [pdirty, mdirty, midi, ldirty].any? end |
#get ⇒ Object
65 66 67 |
# File 'lib/voicemeeter/event.rb', line 65 def get %i[pdirty mdirty midi ldirty].reject { |ev| !send(ev) } end |
#info(msg = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/voicemeeter/event.rb', line 55 def info(msg = nil) info_msg = msg ? ["#{msg} events."] : [] info_msg << if any? ["Now listening for #{get.join(", ")} events"] else ["Not listening for any events"] end logger.info info_msg.join(" ") end |
#remove(events) ⇒ Object
78 79 80 81 |
# File 'lib/voicemeeter/event.rb', line 78 def remove(events) events = [events] unless events.respond_to? :each events.each { |e| send("#{e}=", false) } end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/voicemeeter/event.rb', line 51 def to_s self.class.name.split("::").last.to_s end |