Class: Cheep::Connector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects) ⇒ Connector

Returns a new instance of Connector.



4
5
6
# File 'lib/connector.rb', line 4

def initialize(objects)
  @objects = objects
end

Instance Attribute Details

#objectsObject (readonly)

Returns the value of attribute objects.



2
3
4
# File 'lib/connector.rb', line 2

def objects
  @objects
end

Instance Method Details

#resolve_connectionsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/connector.rb', line 8

def resolve_connections
  objects.each_with_object([]) do |obj, patch|
    obj.ins.each.with_index do |sender_or_senders, sender_input|
      if sender_or_senders.class == Array
        sender_or_senders.each do |sender|
          patch << connection(sender, obj, sender_input)
        end
      else
        patch << connection(sender_or_senders, obj, sender_input)
      end
    end
  end
end