Class: Rossoc::Ir

Inherits:
Object
  • Object
show all
Defined in:
lib/rossoc/ir.rb

Overview

Ir

Defined Under Namespace

Classes: Rsleep

Instance Method Summary collapse

Constructor Details

#initialize(in_pins, out_pins, table, where, ast, sleep_sec, speed) ⇒ Ir

rubocop:disable Metrics/ParameterLists



10
11
12
13
14
15
16
17
18
19
# File 'lib/rossoc/ir.rb', line 10

def initialize(in_pins, out_pins, table, where, ast,
               sleep_sec, speed)
  @in_pins = in_pins
  @out_pins = out_pins
  @table = table
  @where = where
  @ast = ast
  @sleep = Rsleep.new(sleep_sec)
  @speed = speed
end

Instance Method Details

#resultObject

rubocop:disable Metrics/MethodLength



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rossoc/ir.rb', line 23

def result
  din_pins = Set.new
  ain_pins = Set.new
  dout_pins = Set.new
  aout_pins = Set.new

  [@in_pins, @out_pins].each_with_index do |pins, i|
    pins.each do |pin|
      n = pin.gsub(/din|ain/, '').to_i
      if pin.start_with?('din')
        if i.zero?
          din_pins.add(n)
        else
          dout_pins.add(n)
        end
      elsif i.zero?
        ain_pins.add(n)
      else
        aout_pins.add(n)
      end
    end
  end

  {
    din_pins: din_pins,
    ain_pins: ain_pins,
    dout_pins: dout_pins,
    aout_pins: aout_pins,
    table: @table,
    where: @where,
    ast: @ast,
    sleep: @sleep,
    speed: @speed
  }
end