I like to parse string array and update value, what i have for example:
list= ["beam=0", "active=0", "rate=11", "version=4.1", "delay=5"]
in the above list i want to search for "active" and edit its value, like if "active=0" i want to make it "active=1" , and if its "active=1" i want to make it "active=0".
What i am doing is , but its not correct ,, can someone assist in this:
list.each do |lists|
if lists.include?("active=0")
lists = "active=1"
elsif list.include?("active=1")
lists = "active=0"
end
end
what i expect in the end if list contains active=0 , than output list = ["beam=0", "active=1", "rate=11", "version=4.1", "delay=5"] and if list contains active=1, then output list = ["beam=0", "active=0", "rate=11", "version=4.1", "delay=5"]
hash = { beam: 0, active: 0, rate: 11, version: "4.1", delay: 5 }. That way you could update viahash[:active] = 1.