modes = %x(qres.exe /L).each_line.to_a.drop(3)
modes.each_index do |n|
x = modes[n].match(/[^x]*/)[0]
y = modes[n].match(/(?<=x)(.*)(?=,)/)[0]
c = modes[n].match(/(?<=, )(.*)(?= bits)/)[0]
f = modes[n].match(/(?<=@ )(.*)(?= Hz)/)[0]
modes[n] = { :x => x, :y => y, :c => c, :f => f }
end
puts modes
PATTERN = /(?<width>\d+)x(?<height>\d+)
,\s
(?<color_depth>\d+)\sbits
\s@\s
(?<refresh_rate>\d+)\sHz
/x
modes = %x(qres.exe /L).each_line.drop(3).map do |line|
match = line.match(PATTERN)
{
width: match[:width].to_i,
height: match[:height].to_i,
color_depth: match[:color_depth].to_i,
refresh_rate: match[:refresh_rate].to_i,
}
end
puts modes
puts
puts modes.select {|x| x[:color_depth] == 32 }.sort_by {|x| [x[:width], x[:height]] }
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill