Class: Voicemeeter::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/voicemeeter/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdirty: true, mdirty: true, midi: true, ldirty: false) ⇒ Event

Returns a new instance of Event.



5
6
7
8
9
10
# File 'lib/voicemeeter/event.rb', line 5

def initialize(pdirty: true, mdirty: true, midi: true, ldirty: false)
  @pdirty = pdirty
  @mdirty = mdirty
  @midi = midi
  @ldirty = ldirty
end

Instance Attribute Details

#ldirtyObject

Returns the value of attribute ldirty.



3
4
5
# File 'lib/voicemeeter/event.rb', line 3

def ldirty
  @ldirty
end

#mdirtyObject

Returns the value of attribute mdirty.



3
4
5
# File 'lib/voicemeeter/event.rb', line 3

def mdirty
  @mdirty
end

#midiObject

Returns the value of attribute midi.



3
4
5
# File 'lib/voicemeeter/event.rb', line 3

def midi
  @midi
end

#pdirtyObject

Returns the value of attribute pdirty.



3
4
5
# File 'lib/voicemeeter/event.rb', line 3

def pdirty
  @pdirty
end

Instance Method Details

#add(events) ⇒ Object



54
55
56
57
# File 'lib/voicemeeter/event.rb', line 54

def add(events)
  events = [events] if !events.respond_to? :each
  events.each { |ev| send("#{ev}=", true) }
end

#any?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/voicemeeter/event.rb', line 50

def any?
  [pdirty, mdirty, midi, ldirty].any?
end

#getObject



46
47
48
# File 'lib/voicemeeter/event.rb', line 46

def get
  %w[pdirty mdirty midi ldirty].reject { |ev| !send("#{ev}") }
end

#info(msg = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/voicemeeter/event.rb', line 16

def info(msg = nil)
  info_msg = msg ? ["#{msg} events."] : []
  if any?
    info_msg += ["Now listening for #{get.join(", ")} events"]
  else
    info_msg += ["Not listening for any events"]
  end
  LOGGER.info(info_msg.join(" "))
end

#remove(events) ⇒ Object



59
60
61
62
# File 'lib/voicemeeter/event.rb', line 59

def remove(events)
  events = [events] if !events.respond_to? :each
  events.each { |ev| send("#{ev}=", false) }
end

#to_sObject



12
13
14
# File 'lib/voicemeeter/event.rb', line 12

def to_s
  "#{self.class.name.split("::").last}"
end