Module: EISCP::Dictionary::DictionaryGenerators

Included in:
EISCP::Dictionary
Defined in:
lib/eiscp/dictionary/dictionary_generators.rb

Overview

This module provides methods that can be used to generate command entries that are specified as ranges in the yaml file.

Instance Method Summary collapse

Instance Method Details

#create_balance_commands(zone, command, _value) ⇒ Object

Creates hash object for balance commands



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/eiscp/dictionary/dictionary_generators.rb', line 49

def create_balance_commands(zone, command, _value)
  tmp = {}
  ['-A', '-8', '-6', '-4', '-2', '00', '+2', '+4', '+6', '+8', '+A'].each do |v|
    tmp.merge!(v.to_s =>
      {
        name: v.downcase,
        description: @commands[zone][command][:values]['{xx}'][:description].gsub(/\(.*[\]|)]$/, v),
        models: @commands[zone][command][:values]['{xx}'][:models]
      })
  end
  tmp
end

#create_range_commands(zone, command, value) ⇒ Object

Creates a hash object for range commands like master-volume



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eiscp/dictionary/dictionary_generators.rb', line 13

def create_range_commands(zone, command, value)
  case value.count
  when 3
    range = Range.new(value[0], value[2])
  when 2
    range = Range.new(*value)
  end
  tmp = {}
  range.each do |number|
    tmp.merge!(number.to_s(16).rjust(2, '0').upcase =>
      {
        name: number.to_s,
        description: @commands[zone][command][:values][value][:description].gsub(/\d - \d+/, number.to_s),
        models: @commands[zone][command][:values][value][:models]
      })
  end
  tmp
end

#create_treble_bass_commands(zone, command, value) ⇒ Object

Creates hash object for treble and bass commands



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/eiscp/dictionary/dictionary_generators.rb', line 34

def create_treble_bass_commands(zone, command, value)
  tmp = {}
  ['-A', '-8', '-6', '-4', '-2', '00', '+2', '+4', '+6', '+8', '+A'].each do |v|
    tmp.merge!((value[0] + v.to_s) =>
      {
        name: value[0].downcase + v,
        description: @commands[zone][command][:values]["#{value[0]}{xx}"][:description].gsub(/\(.*[\]|)]$/, v),
        models: @commands[zone][command][:values]["#{value[0]}{xx}"][:models]
      })
  end
  tmp
end