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.



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

def initialize(makeables)
  @makeables = makeables
end

Instance Method Details

#create(behavior_names, starting_port, host) ⇒ Object



8
9
10
11
12
# File 'lib/bane/behavior_maker.rb', line 8

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



14
15
16
# File 'lib/bane/behavior_maker.rb', line 14

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