Class: BalancingAct::Balancer
- Inherits:
-
Object
- Object
- BalancingAct::Balancer
- Defined in:
- lib/balancing_act/balancer.rb
Class Method Summary collapse
-
.process(values) ⇒ Object
Takes in all the arguments being passed through the terminal command as type array of strings.
Class Method Details
.process(values) ⇒ Object
Takes in all the arguments being passed through the terminal command as type array of strings. This will iterate through each of these options and manipulate the string so it can create Server objects. Then it will place each Server into an array ‘n’ times based on the size passed in, so the collection array will have the correctly proportioned values. ex:
- “X:3”, “Y:1”
-
#=> [“X”, “X”, “X”, “Y”]
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/balancing_act/balancer.rb', line 10 def self.process(values) collection = [] values.each do |v| name, size_string = v.split(":") size_int = size_string.to_i server = BalancingAct::Server.new(name, size_int) size_int.times { collection << server } end server = select_server(collection) puts server.name server end |