Class: Bane::BehaviorMaker

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

Instance Method Summary collapse

Constructor Details

#initialize(makeables) ⇒ BehaviorMaker

Returns a new instance of BehaviorMaker.



6
7
8
# File 'lib/bane/behavior_maker.rb', line 6

def initialize(makeables)
  @makeables = makeables
end

Instance Method Details

#create(behavior_names, starting_port, host) ⇒ Object



10
11
12
13
14
# File 'lib/bane/behavior_maker.rb', line 10

def create(behavior_names, starting_port, host)
  behavior_names
    .map { |behavior| makeables.fetch(behavior) { raise UnknownBehaviorError.new(behavior) } }
    .map.with_index { |maker, index| maker.make(starting_port + index, host) }
end

#create_all(starting_port, host) ⇒ Object



16
17
18
# File 'lib/bane/behavior_maker.rb', line 16

def create_all(starting_port, host)
  makeables.sort.map.with_index { |name_maker_pair, index| name_maker_pair.last.make(starting_port + index, host) }
end