How do I iterate through the string comparing dividing the second number
by the first number and only print the output if the number is 90% or
more? Basically the first number is total space and the second number
is used space. If the comparison is 90% or more, then print the vol
name /vol/dept(etc.) along with the %. If the comparison is less than
90% then don’t print it at all. In other words using the two above I
would get
/vol/dept 96.6%
I am sure this is easy but I can’t get my head around it.
Ryan this worked beautifully. Thank you. However, I can’t seem to get
why all of the % signs are in the line puts “%s %.1f%%” % [vol, pct *
100] and what does %s mean?
Ryan D. wrote in post #1067285:
On Jul 3, 2012, at 16:54 , Aleksey V Zapparov wrote:
second number is used space. If the comparison is 90% or more, then
next arr if “vol” == str
next arr if 2 > arr.push(str).count
dept, home = arr
puts “#{dept} VS #{home}”
[]
end
There are many tools in the String toolbox. #scan is often a much more
powerful tool than #split:
Ryan this worked beautifully. Thank you. However, I can’t seem to get
why all of the % signs are in the line puts “%s %.1f%%” % [vol, pct *
100] and what does %s mean?
They are placeholders. Check
“this is a string: %s and this is a number: %d” % [“test”, 27]
=> “this is a string: test and this is a number: 27”
Jesus.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.