class Bane::BehaviorMaker

Attributes

makeables[R]

Public Class Methods

new(makeables) click to toggle source
# File lib/bane/behavior_maker.rb, line 6
def initialize(makeables)
  @makeables = makeables
end

Public Instance Methods

create(behavior_names, starting_port, host) click to toggle source
# 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) click to toggle source
# 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