Class: Voicemeeter::Configs::TOMLStrBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(kind) ⇒ TOMLStrBuilder

Returns a new instance of TOMLStrBuilder.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/voicemeeter/configs.rb', line 11

def initialize(kind)
  @p_in, @v_in = kind[:layout][:strip].values
  @p_out, @v_out = kind[:layout][:bus].values
  @vs_params =
    ["mute = false", "mono = false", "solo = false", "gain = 0.0"] +
      (1..@p_out).map { |i| "A#{i} = false" } +
      (1..@v_out).map { |i| "B#{i} = false" }

  @ps_params = @vs_params + ["comp = 0.0", "gate = 0.0"]
  @bus_params = ["mono = false", "eq = false", "mute = false"]
end

Instance Method Details

#buildObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/voicemeeter/configs.rb', line 23

def build
  "
  Builds a TOML script for the parser
  "
  @ps = (0...@p_in).map { |i| ["[strip_#{i}]"] + @ps_params }
  @ps.map! { |a| a.map { |s| s.gsub("B1 = false", "B1 = true") } }
  @vs =
    (@p_in...(@p_in + @v_in)).map { |i| ["[strip_#{i}]"] + @vs_params }
  @vs.map! { |a| a.map { |s| s.gsub("A1 = false", "A1 = true") } }

  @b = (0...(@p_out + @v_out)).map { |i| ["[bus_#{i}]"] + @bus_params }

  [@ps + @vs + @b].join("\n")
end